Sockets not joining rooms
See original GitHub issueYou want to:
- report a bug
- request a feature
Current behaviour
After updating my socket.io from 1.x
to ^2.1.1
my sockets are not joining any rooms anymore.
Steps to reproduce (if the current behaviour is a bug)
async socketJoinRoom(socket: any, room: string, userId: number) {
await socket.join(room)
// tried this to log all the clients in the room, the room ID is correct but "clients" array is empty
this.io.in(room).clients((err, clients) => {
console.log(room) // loggs the correct room
console.log(clients) // loggs an empty array
})
catSystem.info("User "+userId+" joined socket room '"+room+"'")
}
also this is not working:
this.io.in('myroom').emit('test', {})
Expected behaviour
I expected to get a list of sockets in the room and that messages are emitted to the room.
Note: Emitting to a single socket
works fine.
Setup
- OS: Ubuntu 18.04
- browser: Chrome Version 69.0.3497.81 (64 Bit)
- socket.io version: " ^2.1.1"
- NodeJs version v10.9.0
Any suggestions here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (1 by maintainers)
Top Results From Across the Web
socket.join does not work (socket.io) - Stack Overflow
join calls are doing nothing. After calling socket.join, and then listing the rooms the socket is in, the socket is only connected to...
Read more >Rooms | Socket.IO
A room is an arbitrary channel that sockets can join and leave. It can be used to broadcast events to a subset of...
Read more >Socket.IO - Rooms - Tutorialspoint
You can call the join method on the socket to subscribe the socket to a given channel/room. For example, let us create rooms...
Read more >Chat Rooms With Socket.io - Medium
Rooms : A server-side-only concept that lets you create a room inside ... The only difference is socket.in will not include the sender, ......
Read more >Learn Socket.io In 30 Minutes - YouTube
Socket.io is an amazing library for client/server communication, but it can be a bit confusing to get started with. In this video I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Are You using a namespace? I faced this same problem as stated above and was able to make mine work by changing
io.to.(room)
to
io.of(namespace).to(room)
i also face this problem