WebSockets: Can multiple Events fired in a private channel arrive out of order in client

395 Views Asked by At

I have already read through multiple posts on Websockets which highlights the fact that Websockets run on top on TCP Connection and the order is guaranteed. Since, I am new to `Websockets', I have a small query.

I have a simple application in which I am trying to send a large file (1GB) over a websocket connection. I am using rails gem named websocket-rails on server end and their java script client on front end.

I have created a private channel over which events are fired and date is transmitted one after the other. I transfer 500 lines' at a time fromserver to client' over the same channel as a part of the same websocket connection. Is there a possibility that the packets may arrive at different order by any chance ? Do I need to implement any mechanism to re-order the entire file on the client end?

1

There are 1 best solutions below

0
On

Websockets have no "events" or "channels". They have only messages which are transported as one or multiple frames. The order of the messages and the frames inside the messages stays the same, i.e. no reordering is done and no interleaving with other messages (control frames might interleave).

How this translates to your "private channel" and "events" is unknown since this might be features of a specific library you are using on top of Websockets.