You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am creating a simple pub-sub system in which I have
A socket.io server integrated with uWebSockets and reconnection recovery is enabled
A publisher emitting messages periodically to a certain room
A subscriber listening to messages sent to this room and closing the connection deliberately periodically
The expected behavior is after reconnection the subscriber should receive the buffered messages at reconnection period and continue receiving newer messages. However, what really happens is that the subscriber only receive the buffered messages and doesn't receive any newer ones. I am using socket.io.engine.close() to deliberately close the connection (same happens if you just close the connection from Chrome Dev Tools. The current weird behavior is whenever it is called, a surge of buffered messages is processed by the client all at once. So it seems that room messages are well-received by the client, but they events are not passed to callbacks for some reason. The sever is working properly if an httpServer is used instead.
To Reproduce
Socket.IO server version: 4.7.2
Server
const{ Server }=require("socket.io");const{ App }=require("uWebSockets.js");constapp=newApp();constio=newServer({connectionStateRecovery: {maxDisconnectionDuration: 2*60*1000,skipMiddlewares: true,},cors: {origin: "*",},});io.attachApp(app);io.on("connection",(socket)=>{if(socket.recovered){console.log("A user recovered",socket.id);}else{console.log("A user connected");socket.on("subscribe",(channel)=>{socket.join(channel);console.log(`User subscribed to channel: ${channel}`);});socket.on("publish",(data)=>{io.to(data.channel).emit("message",data.message);});}});app.listen(3000,()=>{console.log("server listening on port 3000");});
constio=require("socket.io-client");constsocket=io("http://localhost:3000");socket.on("connect",async()=>{if(socket.recovered){console.log("Reconnected to server",socket.rooms);}else{socket.emit("subscribe",'my-channel');}});socket.on("message",(data)=>{const{ count }=data;console.log(count);});setInterval(()=>{socket.io.engine?.close();},10000);
Expected behavior
The expected behavior is after reconnection the subscriber should receive the buffered messages at reconnection period and continue receiving newer messages.
Platform:
Device: [i7-8750H CPU, 16 GB RAM]
OS: [Windows 10]
The text was updated successfully, but these errors were encountered:
Describe the bug
I am creating a simple pub-sub system in which I have
socket.io
server integrated withuWebSockets
and reconnection recovery is enabledThe expected behavior is after reconnection the subscriber should receive the buffered messages at reconnection period and continue receiving newer messages. However, what really happens is that the subscriber only receive the buffered messages and doesn't receive any newer ones. I am using
socket.io.engine.close()
to deliberately close the connection (same happens if you just close the connection fromChrome Dev Tools
. The current weird behavior is whenever it is called, a surge of buffered messages is processed by the client all at once. So it seems that room messages are well-received by the client, but they events are not passed to callbacks for some reason. The sever is working properly if anhttpServer
is used instead.To Reproduce
Socket.IO server version:
4.7.2
Server
Socket.IO client version:
4.7.2
Publisher
Subscriber
Expected behavior
The expected behavior is after reconnection the subscriber should receive the buffered messages at reconnection period and continue receiving newer messages.
Platform:
The text was updated successfully, but these errors were encountered: