question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connection closed by remote server, closing code 1008 - compare with cryptofeed library

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
caiusCitirigacommented, Nov 12, 2022

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.

0reactions
caiusCitirigacommented, Nov 14, 2022

Here to update again 😃

After a few researches I’ve found out that this specific error code on Binance it means:

-1008 SERVER_BUSY
Spot server is currently overloaded with other requests. Please try again in a few minutes.

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found