socketio / socket.io-client-swift

Other
5.21k stars 841 forks source link

websocket 重连错误, guard !status.active else 第一次之后,永远return #1403

Open kou8910 opened 2 years ago

kou8910 commented 2 years ago

SocketManager.swift

open func connect() { guard !status.active else { DefaultSocketLogger.Logger.log("Tried connecting an already active socket", type: SocketManager.logType)

        return
    }

    if engine == nil || forceNew {
        addEngine()
    }

    status = .connecting

    engine?.connect()
}

public var active: Bool { return self == .connected || self == .connecting }

第二次重连就不会在进入 engine?.connect(), !status.active 永远为true ,永远return Tried connecting an already active socket

需要修改为 public var active: Bool { return self == .connected }

ldbfrank commented 2 years ago

别用这个 socket.io-client-swift 了,作者不用心,也不维护了。 Socket.io 作为 server 不错,但在 iOS 上并没有稳定可靠的 client SDK.