Why are volatile messages rapidly sent by the server not being received by the client?
See original GitHub issueYou want to:
- report a bug
- request a feature
Current behaviour
When firing off multiple emits from the server, I am getting a behavior I was not expecting for volatile
messages.
When I do a regular emit
in rapid succession via a loop, all messages are received by the client and can be inspected via chrome network inspector. When I change to doing volatile.emit
, I am only receiving the first message (of 100).
The question is, why is this the case?
Additionally, I noticed that if I had a 50ms delay to sending each volatile.emit
message via setTimeout()
then all messages are sent correctly (but of course with a delay). What factors go into this method working as expected, but not immediate volatile.emit
s working like regular emit
s?
Steps to reproduce (if the current behaviour is a bug)
Below is a link to a repo that is a setup of my test between volatile and non volatile messages. https://github.com/GStipick/socketioVolatileTest
Expected behaviour
From my understanding of: The Documentation for volatile messages , I would expect all of the messages to be sent, even if they are not received by the client. If they are indeed being sent, then why is emit
able to be received for all messages, while volatile.emit
is not?
Setup
- OS: Windows 10 (Version 1803) [OS Build 17134.285]
- browser: Firefox/Chrome
- socket.io version: 2.1.1
- node.js version: 10.9.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top GitHub Comments
For future readers:
Please see the documentation here: https://socket.io/docs/v3/emitting-events/#Volatile-events
@wmcmurray that’s a good point, actually! I was not able to find the initial motivation for this feature, which was implemented a while ago.