Skip to content

Commit 492dca2

Browse files
committed
fix: cancel connection
1 parent 794335b commit 492dca2

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Sources/NWWebSocket/Model/Client/NWWebSocket.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ open class NWWebSocket: WebSocketConnection {
526526
// Only schedule disconnection if we haven't already scheduled one
527527
if isDisconnectionNWError(error) && disconnectionWorkItem == nil {
528528
let reasonData = "The websocket disconnected unexpectedly".data(using: .utf8)
529+
// Cancel the zombie connection to ensure reconnect creates a fresh NWConnection
530+
connection?.cancel()
529531
scheduleDisconnectionReporting(closeCode: .protocolCode(.goingAway),
530532
reason: reasonData)
531533
}

0 commit comments

Comments
 (0)