socketio / socket.io-client-swift

Other
5.21k stars 839 forks source link

Socket not connecting #1479

Open muk-y opened 5 months ago

muk-y commented 5 months ago

My socket is not connecting, the version I am using is as follows Server: socket.io: "^4.6.1" Client: Socket.IO-Client-Swift 15.2.0

I am getting error as follows: LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting, 2] LOG SocketIOClient{/}: Joining namespace / LOG SocketManager: Tried connecting socket when engine isn't open. Connecting LOG SocketManager: Adding engine LOG SocketManager: Manager is being released LOG SocketEngine: Starting engine. Server: https://chat.mukeshakya.com.np/ LOG SocketIOClient{/}: Client is being released LOG SocketEngine: Handshaking LOG SocketEngine: Engine is being released

Note: The socket is successfully connecting in website as well as android. Can anybody help me?

Crysis21 commented 5 months ago

I am facing the same issue. I did the configuration similar to socket.io on android, but I can't connect.

Crysis21 commented 5 months ago

@muk-y use this

       var config = SocketIOClientConfiguration()
        config.insert(.extraHeaders(["authorization" : "Bearer \(token)"]))
        config.insert(.path("/socket.io/"))
        config.insert(.useCustomEngine(false))
        config.insert(.forceWebsockets(true))
nuclearace commented 5 months ago

@Crysis21 are you able to test with the latest development branch? I'm having trouble reproducing on that branch. Screenshot shows server upgrading from polling to WS

Screenshot 2024-03-19 at 12 07 37 PM

My basic test code:

func connectSocket() {
    socket.connect(withPayload: ["hello": "world"])
}

manager = SocketManager(socketURL: URL(string:"http://localhost:8087/")!, config: [])

socket = manager.defaultSocket

connectSocket()
muk-y commented 5 months ago

@muk-y use this

       var config = SocketIOClientConfiguration()
        config.insert(.extraHeaders(["authorization" : "Bearer \(token)"]))
        config.insert(.path("/socket.io/"))
        config.insert(.useCustomEngine(false))
        config.insert(.forceWebsockets(true))

I don't have the useCustomEngine property in Socket.IO-Client-Swift 15.2.0. Which version has the property? I have used all the codes besides useCustomEngine but the error is still the same.

TannazParsa commented 3 months ago

@muk-y did you find any solution? I have the same issue

vkhadyka commented 3 months ago

I have the same issue on the latest version of the library.

muk-y commented 3 months ago

@muk-y did you find any solution? I have the same issue

I passed my parameters through string concatination instead of using connectParams. This solved my issue.