vadrsa / SimpleR

High Performance Pure WebSocket Server Library based on SignalR
MIT License
18 stars 3 forks source link

Empty messages are "randomly" skipped #18

Open vadrsa opened 2 months ago

vadrsa commented 2 months ago

The following code in WebSocketServerTransport.cs results in some of the empty messages being skipped.

// Do a 0 byte read so that idle connections don't allocate a buffer when waiting for a read
var result = await socket.ReceiveAsync(Memory<byte>.Empty, token);

if (result.MessageType == WebSocketMessageType.Close)
{
    _gracefulClose = true;
    return;
}

Steps to reproduce

  1. Run an echo server
  2. Send 2 empty messages
  3. One will be echoes back, one will not