'ReceiveAsync's CancellationToken paramtere is doing timeout even if the web socket client is still connected
How do I make ClientWebSocket.ReceiveAsync timeout in 5 seconds only if the web socket client is not connected? The current behavior is that it timeouts no matter what conditions are met, i.e. whether the web socket client is connected or not, which is not the behavior I expect.
var timeOut = new CancellationTokenSource(5000).Token;
var receiveResult = await _clientWebSocket.ReceiveAsync(buffer.Memory, timeOut).ConfigureAwait(false);
Solution 1:[1]
Set the keep alive interval to 5 secs:
_clientWebSocket.Options.KeepAliveInterval = TimeSpan.FromSeconds(5);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ggeorge |
