socketio / socket.io-client-swift

Other
5.22k stars 843 forks source link

SocketIO connected but emit not working #1398

Closed priyankaMatrix closed 2 years ago

priyankaMatrix commented 2 years ago

Socket io connected successfully but emit not working. please help 'Socket.IO-Client-Swift' version 16.0.1 server version 4.4.0

showing log: LOG SocketEngineWebSocket: Sending ws: 2["send","{\n \"recipient_id\" : 19,\n \"sender_id\" : \"29\",\n \"conversation_id\" : \"61c974afdccc7cbf80a78ee7\",\n \"message\" : \"Gggg\"\n}"] as type: 4 LOG SocketEngine: Got message: 2 LOG SocketEngine: Writing ws: has data: false Handling event: ping with data: [] LOG SocketEngineWebSocket: Sending ws: as type: 3

priyankaMatrix commented 2 years ago

I have debug and found that it is name space issue. Earlier I am using code like this: static let manager = SocketManager(socketURL: URL(string: "http://abc.com/chat")!, config: [.log(true), .compress,.connectParams(["id":SessionService.sharedInstance.getIsUserID()])]) Showed me socket connected, but emit was not working.

Now I have changed my code to this: static let manager = SocketManager(socketURL: URL(string: "http://abc.com")!, config: [.log(true), .compress,.connectParams(["id":SessionService.sharedInstance.getIsUserID()])])

within socketio SDK, in SocketManager class, I have changed the default namespace from public var defaultSocket: SocketIOClient { return socket(forNamespace: "/") } to public var defaultSocket: SocketIOClient { return socket(forNamespace: "/chat") }

Now Emit working fine. It would be helpful, if some one from support centre reply and help me to solve the issue. But as soon as I solved it, I have posted here, so that anyone will not stuck on it, like I spent 2 days for it. Please mention the namespace and domain criteria on socket.io-client-swift documentation. Thank you

marctatham commented 1 week ago

Thank you for sharing 🙌