Giter Site home page Giter Site logo

Comments (3)

JKorf avatar JKorf commented on September 16, 2024

Not quite. The Binance websocket doesn't use subscribing. It just connects to an endpoint, and receives data based on what that endpoint is. When a connection is made to an endpoint (say listenkey) which doesn't exist or is expired, the connection attempt will still succeed, it just won't receive any data.

So in the case of a longer network outage, the socket will reconnect just fine, it just won't receive any updates.
You probably can't call a KeepAlive on an expired listenkey, so you'd still need to implement something to restart the stream with a new listenkey when the key is expired.

from cryptoexchange.net.

MartyIX avatar MartyIX commented on September 16, 2024

Not quite. The Binance websocket doesn't use subscribing.

Ah, now I understand your definition of "subscribing".

So in the case of a longer network outage, the socket will reconnect just fine, it just won't receive any updates.

Actually, my analysis tells me that that Binance User Data Stream is not re-subscribed because

https://github.com/JKorf/Binance.Net/blob/5231d56006c1c26a107cbf9f3f6bf5302cb476a0/Binance.Net/BinanceSocketClient.cs#L101

where request = null

and this leads to

handlerList = handlers.Where(h => h.Request != null).ToList();

where handlers without requests are ignored.

So in the end, it behaves as I need. It's a little bit confusing for me as I don't understand what request:

public object? Request { get; set; }

is abstraction for.

from cryptoexchange.net.

JKorf avatar JKorf commented on September 16, 2024

Request is the request object which is sent to the server when it wants to subscribe. Typically it is a model which looks something like this (just an example):

public class SubscribeRequest
{
   public string Method { get; set; } = "Subscribe";
   public string Channel { get; set; }
}

This request object is saved for a handler. In case a reconnect happens the socket needs to resubscribe. It then takes all handlers which have such a subscribe request object and resends that same object to resubscribe to the correct channels.

In case of Binance this isn't needed because it automatically starts sending data based on what endpoint you connected to. So for Binance the request objects are null because they don't exist, and in case of reconnect there is no need to send anything.

from cryptoexchange.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.