0

Is there any good solution to support long polling clients in scenarios like this:

sockets.in("room1").volatile.emit(message);
sockets.in("room2").volatile.emit(message);

The client is in both rooms and is only received the message in one of the rooms. I suppose it has to do with long polling. When I remove "volatile" from the latter emit, then it works - but is there another way?

Side question: Are there any side-effects by not using VOLATILE? Like the server throwing exceptions etc. I can imagine that it comes with abit of overhead. And how many resends does the server perform?

Best regards, Mattias

Mattias
  • 684
  • 3
  • 7
  • 16
  • If you could afford dropping some messages then use volatile because if your users have slow connections your server will be queuing all the unreached messages and that makes your server really slow and even if your clients stay connected they be serving a long queue of old data. Use volatile so messages drop if they are not reached in a certain time. But if you are not using socket.io in games or real-time messaging you should be ok by not using volatile. – Maziyar Jan 02 '14 at 15:07

1 Answers1

0

Actually volatile is more unstable. If polling have not reached server after last data sent, it's gone. You don't need to use volatile. If you do not use it, it will queue up all emit in case of connection has not reached yet and when it reach, it get executed in order. I cannot see any advantage from using volatile from my experience.

Text from Socket.io first page about volatile: "Sometimes certain messages can be dropped. Let's say you have an app that shows realtime tweets for the keyword bieber.

If a certain client is not ready to receive messages (because of network slowness or other issues, or because he's connected through long polling and is in the middle of a request-response cycle), if he doesn't receive ALL the tweets related to bieber your application won't suffer.

In that case, you might want to send those messages as volatile messages."

Paiboon Panusbordee
  • 781
  • 2
  • 10
  • 26
  • What happens with queued messages that belongs to dropped connections? Do they get removed when corresponding socket gets disconnected or do they stay in queue forever? – Mattias Jan 20 '13 at 19:38
  • They get removed if client did not contact server for a period of time. It consider as disconnect and remove all relate variable automatically. – Paiboon Panusbordee Jan 21 '13 at 03:36