Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket not connecting #1479

Open
muk-y opened this issue Mar 17, 2024 · 7 comments
Open

Socket not connecting #1479

muk-y opened this issue Mar 17, 2024 · 7 comments

Comments

@muk-y
Copy link

muk-y commented Mar 17, 2024

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
Copy link

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

@Crysis21
Copy link

@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
Copy link
Member

nuclearace commented Mar 19, 2024

@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
Copy link
Author

muk-y commented Mar 20, 2024

@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
Copy link

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

@vkhadyka
Copy link

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

@muk-y
Copy link
Author

muk-y commented May 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants