The socket.io connection made by second.pug
never receives a message because your server never sends it a message.
Here’s what first.pug
does:
- It creates a socket.io connection to your server.
- When that connection succeeds, it sends a
join123
message to that server.
Here’s what your socket.io server does:
- It listens for connecting clients.
- When a client connects, it puts that client into the
join123
room. - No messages are sent out to any of the connected clients.
Note: there is no listener on the server for the join123
message that the client sent so likely something is wrong there.
Here’s what second.pug
does:
- It create a socket.io connection to your server.
- It listens for a
join123
message to be sent to it.
But, nothing ever sends a join123
message to second.pug, so second.pug never receives that message. first.pug
sends a join123
message to your server, but the server never sends that to anyone else. The act of doing socket.join('join123')
does not cause any messages to be sent. It just adds the socket to a room by that name. If you want the second.pug
to get a join123
message, you would have to write code on your server that actually sends that message either to all connections or somehow just to the second.pug
connection.
CLICK HERE to find out more related problems solutions.