Remote end closed connection without response
Anyone else getting connection disconnect errors? I thought it was me calling the api too many times but Ive done that awhile ago when I first was using the API only and I would actually get a "Too many calls" error telling me that I'm using too much. Now I keep getting this traceback and cant figure out why. It happens right after I have a time.sleep(300) action so any rate limit shouldnt be a problem at that point.
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Programming Projects/Python Courses/BinanceBot/sidebyhalf.py", line 104, in <module>
average15m = Binancewebsocket.movingaverage1hr(pair)
File "D:\Programming Projects\Python Courses\BinanceBot\Binancewebsocket.py", line 23, in movingaverage1hr
candles = client.get_klines(symbol=pair, interval=client.KLINE_INTERVAL_1MINUTE)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 689, in get_klines
return self._get('klines', data=params)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 206, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 180, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 174, in _request
response = getattr(self.session, method)(uri, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
So I had my program running over night with no connection disconnects and today made a wait time LONGER from 180 seconds to 300 and started getting disconnect errors again. So now I'm really confused
sooo no one else has had this issue pop up? I havent seen it in a few weeks. but it seems to be everytime I start using a wait timer in my script that waits for 300 seconds or 5 minutes. It NEVER does this any other time
@sammchardy can you have a look at this traceback code and see if this is a me problem or something in the library thats causing this whenever you have a chance please
traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\util\retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Programming Projects/Python Courses/BinanceBot/btcbotv3.py", line 138, in <module>
orderbook = client.get_orderbook_ticker(symbol=pair)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 908, in get_orderbook_ticker
return self._get('ticker/bookTicker', data=params, version=self.PRIVATE_API_VERSION)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 206, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 180, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\binance\client.py", line 174, in _request
response = getattr(self.session, method)(uri, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\requests\adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
Just had this error as well. Never happened to me before and I would consider my script to be stable. I think this may have been something to do with Binance's servers timing out. Maybe their servers went down today?
Well like my previous post. This specific error only happens when I try to use a 300 second time.sleep command. More time... Less time. Like 60 or 600... Never seen this before. Only today I was playing around and started using that 5 min time out and been getting it again
On Tue, Mar 27, 2018, 8:37 PM cc345, [email protected] wrote:
Just had this error as well. Never happened to me before and I would consider my script to be stable. I think this may have been something to do with Binance's servers timing out. Maybe their servers went down today?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sammchardy/python-binance/issues/199#issuecomment-376720616, or mute the thread https://github.com/notifications/unsubscribe-auth/Ah9eWbTQxjY89cMm8nBwDPdFmm06-bxaks5titsygaJpZM4SUK0R .
I'm getting the same error here. Although everything was fine before, I had my code refresh every 10sec and ran for days solid. Now crashing overnight
I am not able to pinpoint the issue. It seems Binance closes the websocket connection by itself. Any workaround for this?
im getting this error consistently now too - any ideas how to narrow down eg. binance servers, urllib requests/ssl settings, memory leaks, etc?
Me too! Seems to coincide with slow website response, so I would guess general server problems. I'd hate to handle this error on every request, but that may be the most robust solution.
hey!!! how did you get out of that issue?? @alphaharris @Technorocker @pulkitsharma @rexii2300 @cc345
Facing the same issue. did any one found the solution ?
If base_url is not provided, it defaults to api.binance.com.
It's recommended to pass in the base_url parameter, even in production as Binance provides alternative URLs
in case of performance issues:
https://api1.binance.comhttps://api2.binance.comhttps://api3.binance.com
I was not able to resolve it. Perhaps there should be a auto-retry connection system in place. I haven't used this library in years. You can look at some other open source binance bots and check how they do it.
If you use python-binance try this code. while True: try: client = Client(api_key, api_secret) <.... your code> client.close_connection() time.sleep(delay)
I know that's bad practice but it's working.
I am also getting connection exception nowadays. Before, my trade bot has been working perfectly without any connection issue.
Do you have any guess why this happens other than auto-retry connection ?
My network connection is stable as always and nothing changed in my code however there is a connection problem with binance server.
If you use python-binance try this code. while True: try: client = Client(api_key, api_secret) <.... your code> client.close_connection() time.sleep(delay)
I know that's bad practice but it's working.
Sorry to bother you, but I tried this code and it did not work for me, I am just wondering what I am doing wrong. To test it, I wrote this simple code from a bigger Python code I am using.
client = Client(API_KEY, API_SECRET)
symbols = getGainers()
client.close_connection()
print('Connection closed...')
symbols = getGainers()
exit()
The 2nd call to getGainers() is still working even though the connection should have been closed at this stage. I am using python-binance. Can you please help me in pinpointing what might be wrong ? For me, the connection should be closed after client.close_connection() and the 2nd call to getGainers() should fail basically, but that is not what I am experiencing.