fix: address code review findings for WebSocket implementation
- Convert WsReadInfo from mutable struct to class (prevents silent copy bugs) - Add handshake timeout enforcement via CancellationToken in WsUpgrade - Use buffered reading (512 bytes) in ReadHttpRequestAsync instead of byte-at-a-time - Add IAsyncDisposable to WsConnection for proper async cleanup - Simplify redundant mask bit check in WsReadInfo - Remove unused WsGuid and CompressLastBlock dead code from WsConstants - Document single-reader assumption on WsConnection read-side state
This commit is contained in:
@@ -568,7 +568,7 @@ public sealed class NatsServer : IMessageRouter, ISubListAccess, IDisposable
|
||||
}
|
||||
|
||||
// HTTP upgrade handshake
|
||||
var upgradeResult = await WsUpgrade.TryUpgradeAsync(stream, stream, _options.WebSocket);
|
||||
var upgradeResult = await WsUpgrade.TryUpgradeAsync(stream, stream, _options.WebSocket, ct);
|
||||
if (!upgradeResult.Success)
|
||||
{
|
||||
_logger.LogDebug("WebSocket upgrade failed for client {ClientId}", clientId);
|
||||
|
||||
Reference in New Issue
Block a user