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

Clients should not close the WebSocket TCP connection #44

Merged
merged 1 commit into from Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion Sources/HummingbirdWebSocket/WebSocketHandler.swift
Expand Up @@ -194,7 +194,12 @@ actor WebSocketHandler: Sendable {
var buffer = context.allocator.buffer(capacity: 2)
buffer.write(webSocketErrorCode: code)
try await outbound.write(frame: .init(fin: true, opcode: .connectionClose, data: buffer))
outbound.finish()
// Only server should initiate a connection close. Clients should wait for the
// server to close the connection when it receives the WebSocket close packet
// See https://www.rfc-editor.org/rfc/rfc6455#section-7.1.1
if self.type == .server {
outbound.finish()
}
}
}

Expand Down