Fail to access api.binance.com when run over proxy
See original GitHub issueHello,
- OS: Ubuntu 16.04 LTS
- Programming Language version: python 3.7.9
- CCXT version: 1.41.66
I tried to run my program over a socks5 proxy (proxychain-ng) from China, but I encountered the following error:
Traceback (most recent call last):
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File ".../.venv/lib/python3.7/site-packages/urllib3/connection.py", line 421, in connect
tls_in_tls=tls_in_tls,
File ".../.venv/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 429, in ssl_wrap_socket
sock, context, tls_in_tls, server_hostname=server_hostname
File ".../.venv/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/usr/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/usr/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
socket.timeout: _ssl.c:1074: The handshake operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../.venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File ".../.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 531, in increment
raise six.reraise(type(error), error, _stacktrace)
File ".../.venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 385, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File ".../.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 337, in _raise_timeout
self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../.venv/lib/python3.7/site-packages/ccxt/base/exchange.py", line 570, in fetch
verify=self.verify
File ".../.venv/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File ".../.venv/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File ".../.venv/lib/python3.7/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.binance.com', port=443): Read timed out. (read timeout=10)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 295, in <module>
main()
...
File ".../.venv/lib/python3.7/site-packages/ccxt/base/exchange.py", line 1355, in load_markets
markets = self.fetch_markets(params)
File ".../.venv/lib/python3.7/site-packages/ccxt/binance.py", line 616, in fetch_markets
response = getattr(self, method)(query)
File ".../.venv/lib/python3.7/site-packages/ccxt/base/exchange.py", line 466, in inner
return entry(_self, **inner_kwargs)
File ".../.venv/lib/python3.7/site-packages/ccxt/binance.py", line 2545, in request
response = self.fetch2(path, api, method, params, headers, body)
File ".../.venv/lib/python3.7/site-packages/ccxt/base/exchange.py", line 487, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File ".../.venv/lib/python3.7/site-packages/ccxt/base/exchange.py", line 593, in fetch
raise RequestTimeout(details) from e
ccxt.base.errors.RequestTimeout: binance GET https://api.binance.com/api/v3/exchangeInfo
I also double checked by running
curl 'https://api.binance.com/api/v3/exchangeInfo'
over the same proxy, and it returned
curl: (51) SSL: certificate subject name (*.secure.facebook.com) does not match target host name 'api.binance.com'
where (*.secure.facebook.com)
can sometimes be some other domains.
I am wondering if there is anything I can do to fix it? (p.s. The proxy works fine so far for other tasks.)
Thanks a lot!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
API Frequently Asked Questions - Binance
Why did I receive an HTTP 403 error when using the API? ... You have violated the WAF (Web Application Firewall) rules, most...
Read more >problem in get data from binance.com : Forums
code = requests.get('https://info.binance.com/en/currencies/bitcoin'). but i recive below error: requests.exceptions.ProxyError: ...
Read more >Python Binance request blocked by internet provider
I have tried to change the DNS at the browser and at Network Adapter. Nothing are work for me. The error is shown...
Read more >How to Configure Nginx as a Reverse Proxy for Node.js ...
It utilizes a free API from Binance as the data source. ... You can confirm that the nginx service is up and running...
Read more >Configuration - Freqtrade
Set options in the Freqtrade configuration via environment variables. This takes priority over ... exchange.password, API password to use for the exchange.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the quick reply. I have just updated my openssl version from 1.0.1g to 1.1.1g, but the problem is still there. I guess I will need to look around to find out why. The curl command I ran was prefixed with my proxy command
proxychain4 curl ...
, so it should have went over the proxy.It turns out the problem is in my config of the proxy, I manage to fix it by setting up DNS proxy in
proxychain-ng
appropriately. Thanks a lot for the help!