josephg / ShareJS

Collaborative editing in any app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Socket.io in-order message delivery warning still valid?

Thylossus opened this issue ยท comments

Hi,

I'm planning to implement a real-time collaboration platform using ShareJS. Since the documentation seems to be a bit outdated, I'm not quite sure whether the warning "Danger danger socket.io does not guarantee [in-order message delivery]" is still valid.

With version 1.x socket.io introduced major changes and therefore I'm asking myself if it might have changed its message delivery properties. However, I was not able to find any information about this.

Is there any new information regarding the compatibility of ShareJS and socket.io?

Thanks!

I was wondering about this myself. +1 for an authoritative answer...

When using the websocket transport, messages are guaranteed to be in order (thanks to TCP), but other transports supported by socket.io do not guarantee this (e.g. polling), since they may open multiple connections simultaneously (thus creating race conditions).

We ran into this issue when using ShareJS with socket.io at Storify and ended up wrapping the sharejs protocol in our own protocol that guarantees in-order delivery. You basically have to assign a sequence number to each message that increments whenever a message is sent (on both the client and server ends, separately). Both ends then buffer messages that are received out of order until the missing messages come in. Here is an implementation in browserchannel that you can adapt for your own purposes.

@devongovett Thank you for your explanation and the solution! I didn't know that socket.io hasn't implemented in order delivery for their fallback transport mechanisms. Too bad... However, I think with your proposed solution it will also work for my purposes. Therefore thanks again ๐Ÿ‘

and now I wonder how hard it would be to add an in-order option to
socket.io...

On Wed, May 20, 2015 at 10:01 AM Tobias notifications@github.com wrote:

@devongovett https://github.com/devongovett Thank you for your
explanation and the solution! I didn't know that socket.io hasn't
implemented in order delivery for their fallback transport mechanisms. Too
bad... However, I think with your proposed solution it will also work for
my purposes. Therefore thanks again [image: ๐Ÿ‘]

โ€”
Reply to this email directly or view it on GitHub
#375 (comment).

Thanks for the advice, I'll see what I come up with ๐Ÿ‘