You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a HTTP channel is configured with a NIOTypedWebSocketServerUpgrader WebSocket upgrade and a connection fails because shouldUpgrade returned nil the upgrade process should consume all parts of the initial request.
Actual behavior
The .end part is passed onto the HTTP channel pipeline, confusing HTTP request processing as the first part it receives is not a .head.
Steps to reproduce
This can be easily reproduced using the WebSocket samples that come with SwiftNIO
Edit the shouldUpgrade closure of NIOTypedWebSocketServerUpgrader in NIOWebSocketServer/Server.swift:82 to be
channel.eventLoop.makeSucceededFuture(nil)`.
Run NIOWebSocketServer sample
Add break point on line NIOWebSocketServer/Server.swift:214 to catch HTTP part.
for tryawait requestPart in inbound {
Run NIOWebSocketClient sample
When you hit the breakpoint, check contents of requestPart.
SwiftNIO version/commit hash
Swift version 5.10-dev (LLVM e8e5be8d5b39f46, Swift 99e9db868aefd99)
Target: x86_64-unknown-linux-gnu
The text was updated successfully, but these errors were encountered:
Additional information. If your shouldUpgrade function doesn't complete immediately then the .end is consumed prior to the NIOAsyncChannel is added to the pipeline. And your example websocket server channel will hang waiting for a HTTP part that never appears.
Expected behavior
When a HTTP channel is configured with a
NIOTypedWebSocketServerUpgrader
WebSocket upgrade and a connection fails becauseshouldUpgrade
returnednil
the upgrade process should consume all parts of the initial request.Actual behavior
The
.end
part is passed onto the HTTP channel pipeline, confusing HTTP request processing as the first part it receives is not a.head
.Steps to reproduce
This can be easily reproduced using the WebSocket samples that come with SwiftNIO
shouldUpgrade
closure ofNIOTypedWebSocketServerUpgrader
in NIOWebSocketServer/Server.swift:82 to berequestPart
.SwiftNIO version/commit hash
Swift version 5.10-dev (LLVM e8e5be8d5b39f46, Swift 99e9db868aefd99)
Target: x86_64-unknown-linux-gnu
The text was updated successfully, but these errors were encountered: