Failed WebSocket upgrade throws `inappropriateOperationForState` error
Expected behavior
WebSocket client should call notUpgradingCompletionHandler from NIOTypedHTTPClientUpgradeConfiguration when WebSocket server refuses a connection.
Actual behavior
WebSocket upgrade throws inappropriateOperationForState error
Steps to reproduce
This can be easily reproduced using the WebSocket samples that come with SwiftNIO
- Edit the
shouldUpgradeclosure ofNIOTypedWebSocketServerUpgraderin NIOWebSocketServer/Server.swift line 82 to be
channel.eventLoop.makeSucceededFuture(nil)`.
- Run NIOWebSocketServer sample
- Run NIOWebSocketClient sample
SwiftNIO version/commit hash
Swift version 5.10-dev (LLVM e8e5be8d5b39f46, Swift 99e9db868aefd99) Target: x86_64-unknown-linux-gnu
Thanks for filing this. I will take a look!
One of the reasons I was receiving inappropriateOperationForState was the server wasn't returning a response to the WebSocket upgrade request, it was just closing the connection. If I return a response everything is ok.
I guess we still shouldn't be receiving a inappropriateOperationForState error though even if the server closes the connection