aspnet / SignalR

[Archived] Incredibly simple real-time web for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
2.38k stars 446 forks source link

Avoid zero-byte send in WebSockets #3326

Closed BrennanConroy closed 6 years ago

BrennanConroy commented 6 years ago

The motivation behind this was a flaky test that started appearing in some PRs because of a race between the client closing the connection when it received all the bytes and the 0-byte write being sent.

Now we write one segment behind where we've read up to, to allow writing a non 0-byte end of message frame.

davidfowl commented 6 years ago

The motivation behind this was a flaky test that started appearing in some PRs because of a race between the client closing the connection when it received all the bytes and the 0-byte write being sent.

C# tests right? I believe its the only client that doesn't buffer the websocket frames.

analogrelay commented 6 years ago

I'm fine with making more stuff internal so it can be accessed directly too, so you don't have to dive through layers of mocking.

analogrelay commented 6 years ago

Actually yeah, it's not that hard. The main method (SendAsync(this WebSocket ws, ROS<byte>...)) is public on an internal type already. A little IVT here, a mock WebSocket there and you should be able to test it.

BrennanConroy commented 6 years ago

:up: 📅 with test