Closed harrystuart closed 1 year ago
Closing this issue as it is evident that the onus is on the implementor to handle this.
Having the exact same issue for some long events. Any updates? or possible workaround?
Here is a quick workaround, create a new implementation of MarketDataWebSocket and pass larger buffer size to the BinanceWebSocket class
public class ExMarketDataWebSocket : BinanceWebSocket
{
private const string DEFAULT_USER_DATA_WEBSOCKET_BASE_URL = "wss://stream.binance.com:9443";
public ExMarketDataWebSocket(string stream, string baseUrl = "wss://stream.binance.com:9443")
: base(new BinanceWebSocketHandler(new ClientWebSocket()), baseUrl + "/ws/" + stream, 50_000)
{
}
public ExMarketDataWebSocket(string stream, IBinanceWebSocketHandler handler, string baseUrl = "wss://stream.binance.com:9443")
: base(handler, baseUrl + "/ws/" + stream, 50_000)
{
}
public ExMarketDataWebSocket(string[] streams, string baseUrl = "wss://stream.binance.com:9443")
: base(new BinanceWebSocketHandler(new ClientWebSocket()), baseUrl + "/stream?streams=" + string.Join("/", streams), 50_000)
{
}
public ExMarketDataWebSocket(string[] streams, IBinanceWebSocketHandler handler, string baseUrl = "wss://stream.binance.com:9443")
: base(handler, baseUrl + "/stream?streams=" + string.Join("/", streams), 50_000)
{
}
}
and ExMarketDataWebSocket instead of MarketDataWebSocket.
Reproduction steps
Simply listening to the websocket.
Expected behavior
Receipt of clean, complete, json deserialisable messages.
Actual Behavior
I get incomplete messages from
BinanceWebSocket.OnMessageReceived
. This is due to the buffer filling up. Can the buffer be dynamically expanded? What is the best practice here? An example message:{"e":"depthUpdate","E":1665578700816,"s":"BTCUSDT","U":25597310584,"u":25597310880,"b":[["19122.59000000","0.00000000"],["19122.27000000","0.00000000"],["19122.26000000","0.00000000"],["19122.22000000","0.00000000"],["19122.01000000","0.00000000"],["19122.00000000","0.00000000"],["19121.95000000","0.00000000"],["19121.94000000","0.00000000"],["19121.92000000","0.00000000"],["19121.91000000","0.00000000"],["19121.89000000","0.00000000"],["19121.85000000","0.00000000"],["19121.74000000","0.00000000"],["19121.73000000","0.00000000"],["19121.65000000","0.00000000"],["19121.64000000","0.00000000"],["19121.63000000","0.00000000"],["19121.61000000","0.00000000"],["19121.54000000","0.00000000"],["19121.53000000","0.00000000"],["19121.47000000","0.00000000"],["19121.46000000","0.00000000"],["19121.41000000","0.00000000"],["19121.31000000","0.00000000"],["19121.30000000","0.00000000"],["19121.25000000","0.00000000"],["19121.16000000","0.00000000"],["19121.15000000","0.00000000"],["19121.13000000","0.00000000"],["19121.12000000","0.00000000"],["19121.09000000","0.00000000"],["19120.99000000","0.00000000"],["19120.98000000","0.00000000"],["19120.93000000","0.00000000"],["19120.92000000","0.00000000"],["19120.87000000","0.00000000"],["19120.86000000","0.00000000"],["19120.80000000","0.00000000"],["19120.79000000","0.00000000"],["19120.75000000","0.00000000"],["19120.73000000","0.00000000"],["19120.67000000","0.00000000"],["19120.63000000","0.00000000"],["19120.62000000","0.00000000"],["19120.60000000","0.00000000"],["19120.57000000","0.00000000"],["19120.45000000","0.00000000"],["19120.44000000","0.00000000"],["19120.39000000","0.00000000"],["19120.33000000","0.00000000"],["19120.26000000","0.00000000"],["19120.23000000","0.00000000"],["19120.20000000","0.00000000"],["19120.19000000","0.00000000"],["19120.17000000","0.00000000"],["19120.01000000","0.00000000"],["19120.00000000","0.00000000"],["19119.97000000","0.00000000"],["19119.95000000","0.00000000"],["19119.83000000","0.00000000"],["19119.79000000","0.00000000"],["19119.78000000","0.00000000"],["19119.75000000","0.00000000"],["19119.59000000","0.00000000"],["19119.55000000","0.00000000"],["19119.51000000","0.40733000"],["19119.50000000","0.00060000"],["19119.28000000","0.00000000"],["19119.26000000","0.00000000"],["19119.22000000","0.00000000"],["19119.18000000","0.03287000"],["19119.16000000","0.00000000"],["19119.15000000","0.00000000"],["19118.73000000","0.00000000"],["19118.72000000","0.00000000"],["19118.52000000","0.00000000"],["19118.50000000","0.07800000"],["19118.44000000","0.09500000"],["19118.39000000","0.00000000"],["19118.21000000","0.32017000"],["19118.20000000","0.00000000"],["19118.12000000","0.00000000"],["19118.10000000","0.00000000"],["19117.94000000","0.07600000"],["19117.85000000","0.00000000"],["19117.78000000","0.42579000"],["19117.77000000","0.27300000"],["19117.76000000","0.00000000"],["19117.69000000","0.00000000"],["19117.44000000","0.00000000"],["19117.20000000","0.41834000"],["19117.19000000","0.00000000"],["19117.09000000","0.00000000"],["19116.95000000","0.78453000"],["19116.92000000","0.00000000"],["19116.76000000","0.00000000"],["19116.75000000","0.00400000"],["19116.71000000","0.00000000"],["19116.70000000","0.10000000"],["19116.56000000","0.00000000"],["19116.24000000","0.25735000"],["19116.13000000","0.00000000"],["19116.06000000","0.99761000"],["19115.91000000","0.00000000"],["19115.86000000","0.00000000"],["19115.76000000","0.00000000"],["19115.33000000","0.00000000"],["19115.23000000","0.08414000"],["19115.01000000","0.00000000"],["19114.74000000","0.00000000"],["19114.70000000","0.00000000"],["19114.26000000","0.00000000"],["19114.19000000","0.00000000"],["19113.25000000","0.00000000"],["19112.68000000","0.07000000"],["19112.51000000","0.00000000"],["19112.45000000","0.04000000"],["19112.42000000","0.00000000"],["19112.39000000","0.00000000"],["19112.32000000","0.08685000"],["19112.25000000","0.91407000"],["19111.98000000","0.62791000"],["19111.42000000","0.00000000"],["19111.41000000","0.00000000"],["19110.97000000","0.03954000"],["19110.86000000","0.00000000"],["19110.50000000","0.23989000"],["19110.29000000","0.09071000"],["19109.84000000","0.01000000"],["19109.37000000","0.10460000"],["19109.00000000","0.00000000"],["19106.21000000","0.00000000"],["19105.49000000","1.00718000"],["19101.10000000","0.05959000"],["19090.23000000","0.00000000"],["19087.44000000","0.06990000"],["19084.53000000","0.00000000"],["19084.08000000","0.00525000"],["15003.00000000","3.50219000"]],"a":[["19120.02000000","0.02737000"],["19120.27000000","0.03145000"],["19120.61000000","0.05911000"],["19120.83000000","0.05807000"],["19121.20000000","0.00000000"],["19121.22000000","0.04000000"],["19121.26000000","0.02615000"],["19121.28000000","0.07359000"],["19121.29000000","0.04000000"],["19121.31000000","0.00000000"],["19121.32000000","0.00000000"],["19121.34000000","0.06686000"],["19122.07000000","0.21531000"],["19122.08000000","0.00000000"],["19122.09000000","0.02000000"],["19122.14000000","0.04000000"],["19122.20000000","0.02615000"],["19122.23000000","0.14000000"],["19122.33000000","0.00000000"],["19122.38000000","0.02615000"],["19122.43000000","0.00000000"],["19122.55000000","0.00000000"],["19122.81000000","0.00000000"],["19122.84000000","0.24513000"],["19122.87000000","0.00000000"],["19122.88000000","0.03875000"],["19123.13000000","0.00000000"],["19123.23000000","0.00900000"],["19123.30000000","0.59479000"],["19123.31000000","0.00000000"],["19123.32000000","0.00687000"],["19123.34000000","0.00000000"],["19123.35000000","0.00000000"],["19123.41000000","0.10553000"],["19123.42000000","0.00000000"],["19123.67000000","0.02480000"],["19123.70000000","0.00000000"],["19123.79000000","0.49407000"],["19123.80000000","0.00000000"],["19123.83000000","0.00000000"],["19123.84000000","0.09284000"],["19123.85000000","0.00000000"],["19123.86000000","0.00000000"],["19123.87000000","0.00000000"],["19123.89000000","0.00000000"],["19123.91000000","0.00669000"],["19124.25000000","0.00143000"],["19124.30000000","0.00000000"],["19124.31000000","0.00000000"],["19124.46000000","0.00000000"],["19124.49000000","0.03800000"],["19124.65000000","0.06000000"],["19124.70000000","0.00000000"],["19124.78000000","0.00672000"],["19125.02000000","0.00525000"],["19125.89000000","0.07251000"],["19126.09000000","0.00000000"],["19126.61000000","0.06846000"],["19126.65000000","0.10000000"],["19126.69000000","0.00653000"],["19126.70000000","0.08044000"],["19126.71000000","0.00000000"],["19126.78000000","0.00000000"],["19126.80000000","1.75155000"],["19127.29000000","0.08250000"],["19127.44000000","0.94262000"],["19127.47000000","0.00000000"],["19127.99000000","0.00000000"],["19128.01000000","0.02874000"],["19128.02000000","0.20000000"],["19128.05000000","0.09740000"],["19128.08000000","0.17250000"],["19128.24000000","0.05250000"],["19128.39000000","0.11250000"],["19128.52000000","0.03999000"],["19128.85000000","0.00000000"],["19128.96000000","0.42638000"],["19129.20000000","0.00000000"],["19129.29000000","0.00662000"],["19129.33000000","0.00000000"],["19129.34000000","0.01303000"],["19129.51000000","0.00000000"],["19129.94000000","0.12695000"],["19130.24000000","0.01007000"],["19130.26000000","0.00000000"],["19130.89000000","0.00000000"],["19130.99000000","0.00000000"],["19131.05000000","0.09412000"],["19131.22000000","0.47062000"],["19131.42000000","0.04000000"],["19131.65000000","0.01575000"],["19131.76000000","0.00000000"],["19131.86000000","0.00000000"],["19132.49000000","1.01162000"],["19132.74000000","0.00000000"],["19132.85000000","0.00000000"],["19133.25000000","0.00000000"],["19133.51000000","0.16000000"],["19133.79000000","0.00000000"],["19133.84000000","0.01000000"],["19134.07000000","0.00000000"],["19134.18000000","0.05137000"],["19135.00000000","0.07600000"],["19135.11000000","0.00000000"],["19135.17000000","1.22618000"],["19135.42000000","0.00000000"],["19137.00000000","0.00000000"],["19137.81000000","0.12181000"],["19140.61000000","0.00000000"],["19141.43000000","0.00000000"],["19142.27000000","1.01110000"],["19144.34000000","0.00000000"],["19146.24000000","0.00000000"],["19152.53000000","0.36541000"],["
.NET version
.NET Framework 6.0.x
Operating system
Windows
Environment
No response
dotnet --info
No response