emit during connection lost, automatically re-emit?
See original GitHub issueHey there, I am developing a chat app in nodeJS and ReactJS.
Server:
socket.on("new message", data => {
console.log(data);
})
Client:
const message = {content: "hello"}
socket.emit("new message", message);
However when the client has a connection problem and then gets back online, it sometimes resends the previous emit and sometimes it doesn’t. Can anyone tell me why this is happening randomly?
Or generally asked: When a client drops his connection for a quick time, what happens with the emitted messages during that time? Does it get re-emitted, and if yes, how?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Socket.io disconnected unexpectedly - Stack Overflow
The first socket was disconnected unexpectedly and another connection is published without front-end's awareness so front-end never send a ...
Read more >Kotlin's Flow in ViewModels: it's complicated - Christophe Beyls
A graph illustrating the ViewModel Scope in relation to the Activity ... will re-emit the latest value when the flow collection restarts.
Read more >NRS: CHAPTER 487 - REPAIR, REMOVAL AND DISPOSAL ...
NRS 487.039 Vehicle towed from or immobilized in facility for parking or at ... automatic suspension of license if deposit is reduced or...
Read more >ACER Guidance
10 of REMIT, trade repositories or competent authorities responsible for overseeing and collecting information on trading in emission allowances ...
Read more >2021 Instructions for Form 540 Personal Income Tax ...
You may qualify if you have wage income earned in California and/or net ... by the taxpayer for the taxable year to the...
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
For future readers:
By default, the messages are buffered until reconnection.
There are two possible solutions:
volatile
flag (available in version> 3.0.0
). In that case, the packet is discarded if the socket is not connected:Documention here: https://socket.io/docs/v3/emitting-events/#Volatile-events
Regarding the randomness, that sounds weird, I will see if I can reproduce.
thanks for the swift response. can you please explain how does the server behave when it comes to socket.broadcast.to(roomId)? can we attach volatility to broadcast emits?