Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websockets message loss

When using websockets I noticed some message loss. I am trying to communicate between mobile safari (client) and c#(server). I am using superWebSocket (opensource) as a server, so it might be a server bug...

But the messages are only dropped when the connection is congested (When I send alot of messages). This "reaks" of UDP to me, but I remember reading somewhere that web-sockets are TCP.

Is there any occasion where I might issue a "send" command in javascript, and the receiving side does not get the message?

like image 922
eshalev Avatar asked Jul 21 '11 14:07

eshalev


People also ask

Can WebSocket messages be lost?

Websocket client connections may drop due to intermittent network issue and when connections drop, messages will also be lost.

What are the disadvantages of WebSockets?

The biggest downside to using WebSocket is the weight of the protocol and the hardware requirements that it brings with it. WebSocket requires a TCP implementation, which may or may not be a problem, but it also requires an HTTP implementation for the initial connection setup.

Why WebSockets are not reliable?

It has built-in means of detecting transmission errors or packet corruption and attempting retransmissions in those cases, but delivery can still fail. It guarantees that if the packet is not delivered, the caller will get an error so the caller can know. Since websocket is built on top of TCP, it has the same issue.

Are WebSockets insecure?

WSS is secure, so it prevents things like man-in-the-middle attacks. A secure transport prevents many attacks from the start. In conclusion, WebSockets aren't your standard socket implementation. WebSockets are versatile, the established connection is always open, and messages can be sent and received continuously.


1 Answers

I've been using WebSockets extensively in with high traffic applications and in situations where a single lost message (in either direction) is fatal. I've never seen any messages lost, ever. However, I do recall seeing a post or question somewhere about the same issue and that person was also using superWebSocket for the server. So my strong suspicion is that there is a bug in superWebSocket.

Do you see the same problem if you use a non-mobile browser? It's possible the iOS brower (I assume that's what you mean by mobile Safari) has a WebSocket bug. I've not extensively tested that browser with WebSockets. I have extensively tested Chrome, Firefox (with WebSocket enabled), and Opera (with WebSocket enabled) on Linux and Windows and Safari on Windows.

There is no occasion where a send in Javascript is allowed to not reach the server except if the whole connection fails. If that is happening then there is a bug somewhere.

like image 57
kanaka Avatar answered Oct 19 '22 18:10

kanaka