Connection closed by remote server, closing code 1008 - compare with cryptofeed library
See original GitHub issueI made comparation of two libraries ccxtpro and cryptofeed. I found that if numbers of watched symbols = 199 than ccxtpro returns (Connection closed by remote server, closing code 1008) after > 10 seconds, but cryptofeed still works without error.
Bellow are samples of codes which I used for test. What could be reason of error for ccxtpro?
CCXTPRO
# -*- coding: utf-8 -*-
from asyncio import run, gather
import ccxtpro
print('CCXT Pro Version:', ccxtpro.__version__)
async def loop(exchange, symbol):
while True:
try:
trades = await exchange.watch_trades(symbol)
print(exchange, symbol, len(trades), trades[0]['id'], trades[-1]['id'], trades[0]['timestamp'], trades[-1]['timestamp'])
except Exception as e:
print(str(e))
# raise e # uncomment to break all loops in case of an error in any one of them
# break # you can also break just this one loop if it fails
async def main():
exchange = ccxtpro.binance({'newUpdates': True})
markets = await exchange.load_markets()
symbols = [symbol for symbol in markets.keys()]
symbols = symbols[:199]
await gather(*[loop(exchange, symbol) for symbol in symbols])
await exchange.close()
run(main())
CRYPTOFEED
'''
Copyright (C) 2017-2022 Bryant Moscon - bmoscon@gmail.com
Please see the LICENSE file for the terms and conditions
associated with this software.
'''
from decimal import Decimal
from cryptofeed import FeedHandler
from cryptofeed.defines import CANDLES, BID, ASK, BLOCKCHAIN, FUNDING, GEMINI, L2_BOOK, L3_BOOK, LIQUIDATIONS, OPEN_INTEREST, PERPETUAL, TICKER, TRADES, INDEX
from cryptofeed.exchanges import (Binance)
async def trade(t, receipt_timestamp):
assert isinstance(t.timestamp, float)
assert isinstance(t.side, str)
assert isinstance(t.amount, Decimal)
assert isinstance(t.price, Decimal)
assert isinstance(t.exchange, str)
print(f"Trade received at {receipt_timestamp}: {t}")
def main():
config = {'log': {'filename': 'demo.log', 'level': 'DEBUG', 'disabled': False}}
# the config will be automatically passed into any exchanges set up by string. Instantiated exchange objects would need to pass the config in manually.
f = FeedHandler(config=config)
pairs = Binance.symbols()[:199]
f.add_feed(Binance(symbols=pairs, channels=[TRADES], callbacks={TRADES: trade}))
f.run()
if __name__ == '__main__':
main()
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Websocket connection closed with code 1008 Payload too long
Sometimes my websocket client connection is closed with code=1008, message=Payload too long. What does that mean?
Read more >What causes SSH error: kex_exchange_identification ...
I get the error: kex_exchange_identification : Connection closed by remote host in the server logs. What causes that? I haven't found conclusive ...
Read more >cryptofeed - PyPI
The Cryptofeed library is intended for use by Python developers. Several ways to get/use Cryptofeed: Pip - pip install cryptofeed ...
Read more >ssh_exchange_identification: Connection closed by remote ...
I try to generate RSA1 key, and git bash can find it but it return same error. I use ssh-host-config to generate a...
Read more >2019年10月20日到期删除的国际域名
... 10086mvip.com 1008987.com 1008cq.com 100bitcoinpage.com 100finesdesemana.com ... apple-billingpayment-account-centre.com apple-close.com ...
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
experienced same issue with ccxt 2.1.55. Tried to run trades watch on 200 markets on binance. But it was an occasional error. I believe it was originated due to the fact that I’ve continuously killed and started the app, making ccxt loose track of the actual throttling (?) not sure.
Here to update again 😃
After a few researches I’ve found out that this specific error code on Binance it means:
This happened to me when I was trying to consecutively open a lot of ws subscriptions to spot markets. By throttling a little the subscriptions (I used 1s) the error seems to be gone.
Hope it can help
Update:
The error is still present, and is following the “ping-pong keep-alive error” in the issue #15343 😞
The throttling solves the overload of subscription requests against the server, but when the ping-pong error appears then this error comes back consistently.