watch_order_book error with Binance : Connection closed by remote server, closing code 1008
See original GitHub issueHello,
I upgraded both CCXT and CCXT Pro to the latest version and I receive this error when I try to watch Binance order book for one spot symbol :
File "/home/abc/env/lib/python3.6/site-packages/ccxtpro/binance.py", line 155, in watch_order_book
orderbook = await self.watch(url, messageHash, message, messageHash, subscription)
ccxt.base.errors.NetworkError: Connection closed by remote server, closing code 1008
Error code1008 is not referenced in the Binance API.
What do you think is the reason for this issue and how can I fix it?
Thank you,
This is how I initiate the loop:
async def watch_book(account, client, market, i, j):
while True:
try:
ob = await client.watch_order_book(market.symbol)
except Exception as e:
break
async def wallet_loop(account, loop, i, wallet):
client = getattr(ccxtpro, exchange.exid)({'enableRateLimit': True, 'asyncio_loop': loop, })
ws_loops = [watch_book(account, client, market, i, j) for j, market in enumerate(markets_monitor)]
await asyncio.gather(*ws_loops)
await client.close()
async def main(account, loop, wallets):
wallet_loops = [wallet_loop(account, loop, i, wallet) for i, wallet in enumerate(wallets)]
await asyncio.gather(*wallet_loops)
loop = asyncio.get_event_loop()
gp = asyncio.wait([main(account, loop, wallets)])
loop.run_until_complete(gp)
loop.close()
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Websocket connection closed with code 1008 Payload too long
I'm using python's standard asyncio and websockets library. I can't find anything mentioning payload size at Binance API Documentation. Because ...
Read more >Why does Python requests keep giving me this error? "An ...
The answer is right there in your stack trace: "An existing connection was forcibly closed by the remote host." Binance is closing your ......
Read more >Exchanges — ccxt 2.4.71 documentation
To access a particular exchange from ccxt library you need to create an instance of corresponding exchange class. Supported exchanges are updated frequently ......
Read more >ccxt-dev/ccxt - Gitter
errors.InvalidNonce: binance {"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."} ...
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
@YuriyTigiev try adding more pairs to it to see where it breaks. Then add the database connector. Make sure you use an async connector, for example: https://aioinflux.readthedocs.io/en/stable/
Please find below a reproducible example.
When 4 markets are monitored it throws a
RuntimeError : This event loop is already runningthen returns data, but when 5 markets are monitored it throws the RuntimeError with no data. That is the problemNow, when I replace
breakwithcontinuemy IP address get banned by the remote host (happened yesterday) so I don’t think it’s a workaround.Thanks for your support, Kinzowa