dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

ClientWebsocket delay every +- 4000 bytes #65998

Open JKorf opened 2 years ago

JKorf commented 2 years ago

Description

I'm using the ClientWebsocket to connect to the socket server on Binance, however I've run into an issue where the Response is delay by exactly 1 KeepAliveInterval each +- 4000 bytes. For example, when I have set a 10 second KeepAliveInterval in the socket options and send 3000 bytes to the server the response is received in +-260ms which is a normal latency. If I sent 4500 bytes the response is received in +-10260ms and if I sent 8500 bytes it is 20260ms.

Initially I figured this was something on Binances side but they told me this only seems to happen with the Dotnet socket implementation and that there might be an issue on the client side with that.

Thread discussing this with Binance: https://dev.binance.vision/t/socket-live-subscribing-server-delay/9645

Gist for reproducing the issue: https://gist.github.com/JKorf/afd5bd11f49670b85031df962f37b468

Reproduction Steps

Have a ClientWebsocket and change the KeepAliveInterval while sending a request > 4000 bytes to the server. See gist

https://gist.github.com/JKorf/afd5bd11f49670b85031df962f37b468

Expected behavior

Expected not to have the KeepAliveInterval have any influence on the response time

Actual behavior

Response is delay by KeepAliveInterval

Regression?

No response

Known Workarounds

Sending < 4000 bytes doesn't have the issue

Configuration

Dotnet 6 Windows 10 X64

Other information

No response

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
### Description I'm using the ClientWebsocket to connect to the socket server on Binance, however I've run into an issue where the Response is delay by exactly 1 KeepAliveInterval each +- 4000 bytes. For example, when I have set a 10 second KeepAliveInterval in the socket options and send 3000 bytes to the server the response is received in +-260ms which is a normal latency. If I sent 4500 bytes the response is received in +-10260ms and if I sent 8500 bytes it is 20260ms. Initially I figured this was something on Binances side but they told me this only seems to happen with the Dotnet socket implementation and that there might be an issue on the client side with that. Thread discussing this with Binance: https://dev.binance.vision/t/socket-live-subscribing-server-delay/9645 Gist for reproducing the issue: https://gist.github.com/JKorf/afd5bd11f49670b85031df962f37b468 ### Reproduction Steps Have a ClientWebsocket and change the KeepAliveInterval while sending a request > 4000 bytes to the server. See gist https://gist.github.com/JKorf/afd5bd11f49670b85031df962f37b468 ### Expected behavior Expected not to have the KeepAliveInterval have any influence on the response time ### Actual behavior Response is delay by KeepAliveInterval ### Regression? _No response_ ### Known Workarounds Sending < 4000 bytes doesn't have the issue ### Configuration Dotnet 6 Windows 10 X64 ### Other information _No response_
Author: JKorf
Assignees: -
Labels: `area-System.Net`, `untriaged`
Milestone: -