socket.io-client-swift icon indicating copy to clipboard operation
socket.io-client-swift copied to clipboard

Socket not connecting

Open muk-y opened this issue 1 year ago • 7 comments

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?

muk-y avatar Mar 17 '24 12:03 muk-y

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

Crysis21 avatar Mar 18 '24 15:03 Crysis21

@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))

Crysis21 avatar Mar 19 '24 11:03 Crysis21

@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()

nuclearace avatar Mar 19 '24 16:03 nuclearace

@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.

muk-y avatar Mar 20 '24 00:03 muk-y

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

TannazParsa avatar May 18 '24 17:05 TannazParsa

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

vkhadyka avatar May 21 '24 04:05 vkhadyka

@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.

muk-y avatar May 21 '24 14:05 muk-y