itchat 프로 세 스 를 사용 하여 urllib 3 의 이상 을 만 났 습 니 다.
13541 단어 네트워크 프로 그래 밍
itchat
으로 위 챗 방 어 를 철회 할 때 이런 이상 이 발생 했 고 해당 하 는 코드 를 찾 지 못 했 습 니 다. 마치 urllib 3 라 이브 러 리 의 원인 인 것 같 습 니 다. 0
이 HTTP 응답 코드 를 처리 할 수 없습니다.설마 내 가 urllib 3 를 고 치 러 가 야 하나?Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "" , line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 285, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: HTTP/1.1 0 -
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
six.raise_from(e, None)
File "" , line 2, in raise_from
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 285, in _read_status
raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0 -\r
',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/itchat/components/login.py", line 231, in maintain_loop
i = sync_check(self)
File "/usr/local/lib/python3.6/site-packages/itchat/components/login.py", line 283, in sync_check
r = self.s.get(url, params=params, headers=headers)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0 -\r
',))
그리고 이 걸 찾 으 세 요.https://stackoverflow.com/questions/27619258/httplib-badstatusline 이상 을 포착 하고 패스 하 라 고 했 는데 이 이상 한 코드 가 어디 있 는 지도 모 르 겠 어 요.그리고 앞서 itchat 의 issue 에서 제기 한 질문 을 보고 이런 상황 도 있 었 습 니 다.https://github.com/littlecodersh/ItChat/issues/353 https://github.com/littlecodersh/ItChat/issues/424 하지만 해결 되 지 않 은 것 같 습 니 다.그럼 코드 를 똑바로 보 세 요.이상 스 택 에서 raise 에서 이 이상 한 곳 을 찾 았 습 니 다. 제 컴퓨터 에 서 는
/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py
257 def _read_status(self):
258 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
259 if len(line) > _MAXLINE:
260 raise LineTooLong("status line")
261 if self.debuglevel > 0:
262 print("reply:", repr(line))
263 if not line:
264 # Presumably, the server closed the connection before
265 # sending a valid response.
266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
268 try:
269 version, status, reason = line.split(None, 2)
270 except ValueError:
271 try:
272 version, status = line.split(None, 1)
273 reason = ""
274 except ValueError:
275 # empty version will cause next test to fail.
276 version = ""
277 if not version.startswith("HTTP/"):
278 self._close_conn()
279 raise BadStatusLine(line)
280
281 # The status code is a three-digit number
282 try:
283 status = int(status)
284 if status < 100 or status > 999:
285 raise BadStatusLine(line)
286 except ValueError:
287 raise BadStatusLine(line)
288 return version, status, reason
\ # 284 에서 보 듯 이 상태 코드 는 [100, 999] 사이 의 세 자릿수 여야 하 는데 우리 가 있 는 상태 코드 는 0 이기 때문에 이상 을 던 졌 다. /TODO
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
자바 네트워크 프로 그래 밍 -> 상용 모듈스 트림 소켓 을 만 들 고 지정 한 IP 주소 의 지정 한 포트 번호 에 연결 합 니 다. 이 소켓 의 입력 흐름 을 되 돌려 줍 니 다. 이 소켓 의 출력 흐름 을 되 돌려 줍 니 다. 이 IP 주소 의 호스트 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.