Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 0 additions & 95 deletions .github/workflows/release.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/swift.yml

This file was deleted.

16 changes: 8 additions & 8 deletions Sources/NWWebSocket/Model/Client/NWWebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ open class NWWebSocket: WebSocketConnection {
// Only schedule disconnection if we haven't already scheduled one
if isDisconnectionNWError(error) && disconnectionWorkItem == nil {
let reasonData = "The websocket disconnected unexpectedly".data(using: .utf8)
// Cancel the zombie connection to ensure reconnect creates a fresh NWConnection
connection?.cancel()
scheduleDisconnectionReporting(closeCode: .protocolCode(.goingAway),
reason: reasonData)
}
Expand All @@ -548,19 +550,17 @@ open class NWWebSocket: WebSocketConnection {
}
}


/// Determine if a Network error represents an unexpected disconnection event.
/// - Parameter error: The `NWError` to inspect.
/// - Returns: `true` if the error represents an unexpected disconnection event.
/// - Note: Any POSIX error from the read loop indicates the connection is dead.
/// The previous selective list (ETIMEDOUT, ENOTCONN, ECANCELED, ENETDOWN, ECONNABORTED)
/// missed errors like ENODATA (96) which also indicate a dead connection.
private func isDisconnectionNWError(_ error: NWError) -> Bool {
if case let .posix(code) = error,
code == .ETIMEDOUT
|| code == .ENOTCONN
|| code == .ECANCELED
|| code == .ENETDOWN
|| code == .ECONNABORTED {
if case .posix(_) = error {
return true
} else {
return false
}
return false
}
}