我在调试代码时遇到了问题,因为我无法理解引发的套接字错误。这里是traceback。
Traceback (most recent call last):
File "clickpression.py", line 517, in <module> presser.main()
File "clickpression.py", line 391, in main
File "clickpression.py", line 121, in clickpress self.refresh_proxies(country=country)
File "clickpression.py", line 458, in refresh_proxies self.proxies = self.get_proxies(country=country)
File "helpers.py", line 72, in wrapper return func(*args, **kwargs)
File "clickpression.py", line 264, in get_proxies self.settings.SUPER_PROXY).read().decode('utf-8')
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 463, in open response = self._open(req, data)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 481, in _open '_open', req)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 1210, in http_open return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 1185, in do_open r = h.getresponse()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1171, in getresponse response.begin()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 351, in begin version, status, reason = self._read_status()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 313, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socket.py", line 374, in readinto return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
根据errno
库,Errno 54
是errno.EXFULL
,在python 3中,documentation被解释为exchange full
。
根据我的理解,Connection reset by peer
是Errno 104
,即errno.ECONNRESET
。errno.EXFULL
是什么意思为什么socket会用connection reset by peer
而不是exchange full
来引发错误。和/或两个错误errno.EXFULL
和errno.ECONNRESET
是如何相关的?
PS:我read,errno 54
可能与http代理有关(我在代码中使用代理)。如果是,如何进行?
3条答案
按热度按时间kyks70gy1#
根据
errno
库,Errno 54
是errno.EXFULL
你是通过检查
errno.errorcode[54]
确定的吗?无论如何-这个 *errno
库 * 可能有问题。您可以通过查看errno.h
,e来验证系统上错误代码的含义。例如,在gcc
的帮助下:Python documentation说:
若要将数字错误代码转换为错误消息,请使用os.strerror()。
在您的系统上,错误号54很可能是
ECONNRESET
,而os.strerror(54)
将证明这一点。现在您已经验证了
os.strerror(54)
返回'Exchange full',我很困惑为什么错误号54
和错误字符串Connection reset by peer
不匹配。如果在使用strace
或类似的系统上发生这种情况,我将通过在受影响的进程上使用strace -e network
进一步检查操作系统返回的错误。关于EXFULL的问题:它的含义似乎有些系统依赖性;例如,在Linux上,当没有找到可用的网桥端口号时,EXFULL仅从内核中的少数位置返回,唯一与网络相关的位置是在关于网桥的br_if. c中(其它位置在USB和SCSI驱动器中)。
km0tfn4u2#
我尝试使用Python在www.example.com上使用WebSocket创建硬币市场OKEX.com,因为URL是外部地址,我使用了我们提供的VPN服务,但它仍然可以工作。下面是代码的回溯。
pftdvrlh3#
你可以在你的项目中尝试以下代码:
如果不起作用,请确保服务器打开TLSv1支持。