chronoxor / NetCoreServer

Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
https://chronoxor.github.io/NetCoreServer
MIT License
2.63k stars 550 forks source link

Close status updates #267

Closed john-hollander closed 9 months ago

john-hollander commented 1 year ago

In our testing, the status code was not being sent with no message, as the close(status) method suggested it would. When we tested with the SendCloseAsync methods and included a message, the status was not being set properly, and there was an "index out of bounds" error that caused the connection to not close. These fixes address the problems, and additionally, more close methods have been added so that the message can be more easily included on closures.

Note: we could have put the mask frame content loop outside of the if statement and shared it for both cases by using buffer[i - index] instead, but figured that this way would be slightly faster without the extra operation for regular (non-close) message frames.

john-hollander commented 1 year ago

Note: These changes should fix the following issues:

124

265

chronoxor commented 9 months ago

Fixed in 8.0.1. Thanks for reporting and PR!

john-hollander commented 9 months ago

No problem. Thanks for updating and cleaning everything up. I missed the

bool storeStatus = ((opcode & WS_CLOSE) == WS_CLOSE) && ((buffer.Length > 0) || (status != 0));

update, and I think it caused me a few issues. Your changes should resolve those, thanks!