josephg / ShareJS

Collaborative editing in any app
Other
4.97k stars 454 forks source link

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

Open Thylossus opened 9 years ago

Thylossus commented 9 years ago

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!

vote539 commented 9 years ago

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

devongovett commented 9 years ago

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.

Thylossus commented 9 years ago

@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 :+1:

wmertens commented 9 years ago

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: :+1:]

— Reply to this email directly or view it on GitHub https://github.com/share/ShareJS/issues/375#issuecomment-103801106.

vote539 commented 9 years ago

Thanks for the advice, I'll see what I come up with :+1: