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

NIOTypedWebSocketServerUpgrader hangs when connection is opened and closed without sending any data #2742

Open
adam-fowler opened this issue Jun 14, 2024 · 1 comment · May be fixed by #2756

Comments

@adam-fowler
Copy link
Contributor

adam-fowler commented Jun 14, 2024

Expected behavior

Given a server setup with WebSocket upgrade using NIOTypedWebSocketServerUpgrader and allowRemoteHalfClosure set to true on the childChannel. If I open a connection to this server and close it immediately without sending any data the negotiation future returned from configureUpgradableHTTPServerPipeline on the server should throw a connection closed error.

Actual behavior

The negotiation future never completes leaving the child channel dangling.

If allowRemoteHalfClosure is set to false on the server then the negotiation future throws a inappropriateOperationForState error which isn't ideal but at least I can catch that the client has closed the connection

Steps to reproduce

  1. Using the NIOWebSocketServer.swift example
  2. Add .childChannelOption(ChannelOptions.allowRemoteHalfClosure, value: true) before bind call in run
  3. Use a client to connect and close connection immediately
try await ClientBootstrap(group: MultiThreadedEventLoopGroup.singleton)
    .connect(host: "localhost", port: 8888)
    .flatMap { $0.close() }
    .get()
  1. Note that negotiation future never completes

SwiftNIO version/commit hash

e5a216b

System & version information

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: x86_64-apple-macosx14.0

@Lukasa
Copy link
Contributor

Lukasa commented Jun 17, 2024

Yeah, this is a really good catch. We'd welcome a fix into the server upgrader here to make it aware of half closure.

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

Successfully merging a pull request may close this issue.

2 participants