glitch100 / BinanceDotNet

Official C# Wrapper for the Binance exchange API, with REST and WebSocket endpoints

Home Page:https://www.nuget.org/packages/BinanceDotNet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Websocket Depth message serializations are missing the first updateID ('U') field?

junkomatic opened this issue · comments

Issue Overview

The Official Binance API documentation states that the UpdateID nonce must be validated using BOTH the 'U' (first update ID) and also 'u' (last update ID). Otherwise, there is no way of detecting messages lost due to a brief network interruption. This quite possibly will cause severe depth data corruption over time.

According to the official Binance websocket API docs for depth streams:
"The first processed should have U <= lastUpdateId+1 AND u >= lastUpdateId+1
While listening to the stream, each new event's U should be equal to the previous event's u+1"

I will close this because, as countless others Im sure have discovered:
The Binance websocket feed does not provide the initial U value, despite what the 'official' binance git docs say. However, the feed is generally quite reliable with a solid network connection using the (>'u') field alone for nonce validation. I have been using it for a few weeks now and have encountered no noticeable discrepancy. My usage has included manual reconnects usually every 24 hours, sometimes exceeding 24 hours. i have not tested durations longer than this, but the official documentation suggests that they might disconnect you in 24 hour periods.

i have noticed that it is necessary to reconnect the user data websocket about every hour. is there a keep alive call that i am not aware of?

closing this, the issue is with binance.
i really think this library is great, because it is well designed, but not over-designed. In my mind, it IS the official C# wrapper. Well done!