Merge pull request #1034 from OneSman7/Fix-loosing-packets-on-websocket-connect-failure
Fixed loosing POST packets on web socket connection failure
This commit is contained in:
commit
f7ccf338ad
@ -359,6 +359,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
|
||||
///
|
||||
/// **You shouldn't call this directly**
|
||||
open func doFastUpgrade() {
|
||||
|
||||
if waitingForPoll {
|
||||
DefaultSocketLogger.Logger.error("Outstanding poll when switched to WebSockets," +
|
||||
"we'll probably disconnect soon. You should report this.", type: SocketEngine.logType)
|
||||
@ -371,6 +372,12 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
|
||||
fastUpgrade = false
|
||||
probing = false
|
||||
flushProbeWait()
|
||||
|
||||
// Need to flush postWait to socket since it connected successfully
|
||||
// (moved from flushProbeWait() since it is also called on connected failure)
|
||||
if !postWait.isEmpty {
|
||||
flushWaitingForPostToWebSocket()
|
||||
}
|
||||
}
|
||||
|
||||
private func flushProbeWait() {
|
||||
@ -381,10 +388,6 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So
|
||||
}
|
||||
|
||||
probeWait.removeAll(keepingCapacity: false)
|
||||
|
||||
if postWait.count != 0 {
|
||||
flushWaitingForPostToWebSocket()
|
||||
}
|
||||
}
|
||||
|
||||
/// Causes any packets that were waiting for POSTing to be sent through the WebSocket. This happens because when
|
||||
|
||||
@ -168,7 +168,11 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
|
||||
DefaultSocketLogger.Logger.log("Adding engine", type: SocketManager.logType)
|
||||
|
||||
engine?.engineQueue.sync {
|
||||
|
||||
self.engine?.client = nil
|
||||
|
||||
// Close old engine so it will not leak because of URLSession if in polling mode
|
||||
self.engine?.disconnect(reason: "Adding new engine")
|
||||
}
|
||||
|
||||
engine = SocketEngine(client: self, url: socketURL, config: config)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user