Skip to content

Instantly share code, notes, and snippets.

View JKorf's full-sized avatar

Jan Korf JKorf

  • Meppel, Netherlands
View GitHub Profile
@JKorf
JKorf / program.cs
Created February 28, 2022 14:48
Binance socket response delay icw KeepAlive interval
using System.Diagnostics;
using System.Net.WebSockets;
using System.Text;
var socket = new ClientWebSocket();
socket.Options.KeepAliveInterval = TimeSpan.FromSeconds(15);
socket.Options.SetBuffer(65536, 65536); // Setting it to anything bigger than 65536 throws an exception in .net framework
await socket.ConnectAsync(new Uri("wss://stream.binance.com:9443/stream"), default);
var readThread = new Thread(async () =>
@JKorf
JKorf / gist:0c7789dce19e3639ece83db737c227a0
Last active May 23, 2022 19:26
Bybit socket keepalive interval sending incrementally more messages, resulting in increasing network usage even though the actual data being received is very limited
using System.Diagnostics;
using System.Net.WebSockets;
using System.Text;
var socket = new ClientWebSocket();
socket.Options.KeepAliveInterval = TimeSpan.FromSeconds(1);
socket.Options.SetBuffer(65536, 65536);
await socket.ConnectAsync(new Uri("wss://stream.bybit.com/spot/quote/ws/v2"), default);
var readThread = new Thread(async () =>