io.to(socketid).emit() not working #4449
Replies: 4 comments 6 replies
-
Hi, this shall help you. This method you attempted will NOT work as it will send it to everyone in the room. |
Beta Was this translation helpful? Give feedback.
-
Same problem here I am using Socket.IO version 3.x and I want to emit to a particular socket ( private messaging kind ) even though client is connected to the socket server I am using node JS version 14.19.0 in backend and in frontend we have iOS app which does not receive this event |
Beta Was this translation helpful? Give feedback.
-
after each socket connection add the user to his socket channnel
then you can emit to the socket id
|
Beta Was this translation helpful? Give feedback.
-
I had the same problem, the code below works for me server.js |
Beta Was this translation helpful? Give feedback.
-
Hi.
Im having the following line:
io.to(toKey).emit("sendInfo", "<response>" + socket.id + "</response>");
toKey is the socket id of another connection. Im using chrome for client 1 and edge for client 2.
My problem is that there is nothing happening at all. Its seems to not get executed, but also is not throwing any error. Im executing io.to in the index.js File (server).
Updated to the latest node.js version as well and same for npm.
This is the code for the event
its not being triggered. If i do io.emit it works. same as if i do io.to(socket.id).emit(..) (my id).
Its Node.js 16.16.0 and Socket.io.js v4.5
Beta Was this translation helpful? Give feedback.
All reactions