Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

How to deal with WebSocket stream.binance.com session duration limit (24h) #112

Closed
denis-itskovich opened this issue Apr 12, 2018 · 10 comments

Comments

@denis-itskovich
Copy link

denis-itskovich commented Apr 12, 2018

In official Binance API documentation, there is a following limitation:

A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark

  • What is the recommended way of dealing with max session duration of 24 hours for websocket streams?
  • Is it the correct way to close BinanceApiWebSocketClient and create a new one every 24 hours?
  • Are there plans to perform reconnecting automatically by the client, behind the scenes (and restoring all subscribed channels)?

Please note, that this question is not related to handling idle timeout and keeping session alive. The question is about handling maximum session duration.

@ig-dev
Copy link

ig-dev commented May 13, 2018

Does this answer your question? -> #81

@joaopsilva
Copy link
Member

This has since been fixed in #133.

@denis-itskovich
Copy link
Author

This has since been fixed in #133.

As far as I understand, #133 refers to the keeping session alive when idle. My question was related to this:

A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark

Quoted from Binance official API doc

Can you reopen this issue, please?

@hp8wvvvgnj6asjm7
Copy link

lol how come nobody understood the question?

@Alihasnat10
Copy link

Did anyone find the answer to this query? Binance web socket connection is only valid for 24 hours. Is there any way to reconnect after 24 hours?

@jorinator
Copy link

Can this issue be reopened? It seems like there still isn't a solution after 4 years.

@Alihasnat10
Copy link

I solved this issue by setting a counter that counted the time of opening the socket. I close the socket at the 23rd hour and restart it. It is working perfectly fine.

@lokakshi
Copy link

@Alihasnat10 Could you pls share code reference for :How to deal with WebSocket stream.binance.com session duration limit (24h)

@Alihasnat10
Copy link

I have lost the code. Follow these steps:

  1. Note the time when binance socket is created.
  2. If the time is greater than 23 hours:
    a. Close the web socket
    b. Start the web socket again

@lokakshi
Copy link

@Alihasnat10 thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants