- Notifications
You must be signed in to change notification settings - Fork10.1k
Intermittent message loss: messages not received on client despite being sent from server#5416
-
ProblemWe're experiencing an intermittent issue where messages sent from the server via Socket.IO sometimes don't appear on the client widget, even though:
Environment
ConfigurationconstsocketConfig={path:'/sockets-live-chat/socket.io',transports:['websocket','polling'],reconnection:true,reconnectionAttempts:10,reconnectionDelay:2000,reconnectionDelayMax:10000,timeout:30000,connectionStateRecovery:true,pingTimeout:60000,pingInterval:25000,forceNew:true,}; Current ImplementationWe're using a custom event socket.on('sendMessage',(message:SocketMessage,callback)=>{// Process messagehandleMessage(message);// Acknowledge MESSAGE eventsif(typeofcallback==='function'&&message.event==='MESSAGE'){callback({ack:true});}}); Questions
What We've Tried
Expected BehaviorAll messages sent from the server should be received and processed by the client, even during reconnection attempts or connection state changes. Actual BehaviorMessages intermittently stop appearing on the client widget, even though:
Additional ContextThis is a live chat widget where message reliability is critical. The issue occurs randomly during active conversations, making it difficult to reproduce. |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment
-
Hi! That's indeed a bit worrying.
Yes, if the socket is not connected, it won't receive the messages, unless you enable the connection state recovery feature and it succeeds (you can check the Reference:https://socket.io/docs/v4/client-api/#socketrecovered Do you know whether the weird behavior happens during temporary disconnections?
I don't think so, though that's hard to prove.
As said above, you can also check the
Please note that the recovery does not always succeed, in that case you have to resend the missed messages to the client. |
BetaWas this translation helpful?Give feedback.