Skip to content

Commit 6bbb308

Browse files
fix leak, wss links, errors from other pr
1 parent 186807d commit 6bbb308

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Source/SocketIO/Engine/SocketEngine.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate,
572572
polling = true
573573
probing = false
574574
invalidated = false
575+
session?.invalidateAndCancel()
575576
session = Foundation.URLSession(configuration: .default, delegate: sessionDelegate, delegateQueue: queue)
576577
sid = ""
577578
waitingForPoll = false
@@ -723,6 +724,13 @@ open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate,
723724

724725
if let error = error as? WSError {
725726
didError(reason: "\(error.message). code=\(error.code), type=\(error.type)")
727+
} else if let error = error as? HTTPUpgradeError {
728+
switch error {
729+
case let .notAnUpgrade(int, _):
730+
didError(reason: "notAnUpgrade. code=\(int)")
731+
case .invalidData:
732+
didError(reason: "invalidData")
733+
}
726734
} else if let reason = error?.localizedDescription {
727735
didError(reason: reason)
728736
} else {

Source/SocketIO/Manager/SocketManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ open class SocketManager: NSObject, SocketManagerSpec, SocketParsable, SocketDat
575575

576576
_config = config
577577

578-
if socketURL.absoluteString.hasPrefix("https://") {
578+
if socketURL.absoluteString.hasPrefix("https://") || socketURL.absoluteString.hasPrefix("wss://") {
579579
_config.insert(.secure(true))
580580
}
581581

0 commit comments

Comments
 (0)