Can't connect using official SDK, please help to see

用的 binance-connector-python
简单的几行代码
from binance.spot import Spot

client = Spot()
print(client.time())

老是抱错啊,应该是网络问题,也翻墙了是日本的节点,就是不知道应该怎么解决,哪位大神给看看?
import sys; print(‘Python %s on %s’ % (sys.version, sys.platform))
sys.path.extend([’/Users/joss/Documents/project/python/one’])
PyDev console: starting.
Python 3.8.4 (default, Jul 14 2020, 02:58:48)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin

runfile(’/Users/joss/Documents/project/python/one/Bin_Test.py’, wdir=’/Users/joss/Documents/project/python/one’)
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “/usr/local/lib/python3.8/site-packages/urllib3/connection.py”, line 416, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 1040, in _create
self.do_handshake()
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.8/site-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py”, line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py”, line 769, in reraise
raise value.with_traceback(tb)
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “/usr/local/lib/python3.8/site-packages/urllib3/connection.py”, line 416, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 449, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/ssl
.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 1040, in _create
self.do_handshake()
File “/usr/local/Cellar/python@3.8/3.8.4/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(54, ‘Connection reset by peer’))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “”, line 1, in
File “/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py”, line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File “/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py”, line 18, in execfile
exec(compile(contents+"\n", file, ‘exec’), glob, loc)
File “/Users/joss/Documents/project/python/one/Bin_Test.py”, line 4, in
print(client.time())
File “/usr/local/lib/python3.8/site-packages/binance/spot/market.py”, line 35, in time
return self.query(url_path)
File “/usr/local/lib/python3.8/site-packages/binance/api.py”, line 68, in query
return self.send_request(“GET”, url_path, payload=payload)
File “/usr/local/lib/python3.8/site-packages/binance/api.py”, line 115, in send_request
response = self._dispatch_request(http_method)(**params)
File “/usr/local/lib/python3.8/site-packages/requests/sessions.py”, line 555, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/local/lib/python3.8/site-packages/requests/sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.8/site-packages/requests/sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.8/site-packages/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, ConnectionResetError(54, ‘Connection reset by peer’))

国内无法连上,必须用vpn

1 Like

原来是代码里添加本机代理ip
proxies = { ‘https’: ‘http://127.0.0.1:41091’ }
client = Client(proxies=proxies)