Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed WebSocket upgrade throws inappropriateOperationForState error #2631

Open
adam-fowler opened this issue Jan 26, 2024 · 2 comments
Open

Comments

@adam-fowler
Copy link
Contributor

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

  1. Edit the shouldUpgrade closure of NIOTypedWebSocketServerUpgrader in NIOWebSocketServer/Server.swift line 82 to be
channel.eventLoop.makeSucceededFuture(nil)`.
  1. Run NIOWebSocketServer sample
  2. Run NIOWebSocketClient sample

SwiftNIO version/commit hash

Swift version 5.10-dev (LLVM e8e5be8d5b39f46, Swift 99e9db868aefd99)
Target: x86_64-unknown-linux-gnu

@FranzBusch
Copy link
Contributor

Thanks for filing this. I will take a look!

@adam-fowler
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants