MultiversX Tracker is Live!

Binance websocket stream hangs after a certain amount of time

Binance

Cryptocoins Exchanges / Binance 235 Views

Binance websocket stream hangs after a certain amount of time

I'm new to coding and trading, but I'm learning both.

I've been using the Binance websocket and the python-binance wrapper to access it. I tested streaming the price of BTCUSDT from the aggTrade stream using this simple python code.

After some time, the stream just hangs and doesn't give any errors.

The price hangs somewhere after 3 hours of run time

The Binance docs say:

The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed.

I'm not exactly sure how to send a ping, I tried searching for the issue online but didn't find anything helpful. client.ping() does not seem to work.

The solutions in this post are for keeping user data streams alive as far as I understand, and comments on this post recommends using Unicorn Binance Websockets because it handles reconnects. I tried but too complicated for me to use right now.

Do any of you guys know how I can fix this to get an uninterrupted stream for at least 24 hours using python-binance? Thanks in advance <3

P.S. The API is fine, I just want to figure out how to use websockets.

submitted by /u/jenderfluwid
[link] [comments]

Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments