Moisés
Moisés

Reputation: 1494

It is possible that websocket client disconnect for receive to many packs at once?

I'm doing a video chat with WebSockets, but facing i weird problem.

When using only the chat(text messages) everything works fine, than when i start the video, again, all fine sending and receiving, BUT when a send text messages while transmitting the video the receiver of the text SOMETIMES disconnects by itself. Completely random, sometimes after 3 messages, other times after 10, doesn't matter the size of the text, 1 or 20 chars.

websocket.onerror function(msg) {msg.data} 

returns undefined, and console.dir(msg) return 'WebSocket connection to 'ws://127.0.0.1:9000/' failed: Could not decode a text frame as UTF-8.', but how couldn't decode a text that i already had sended lots of times?

My only idea is that the server may be sending packs faster than the browser can handle. As i'm running local it's kind the fastest speed possible.

Any thoughts or faced the same problem? I red a lot of that, but no solutions for this.

Upvotes: 1

Views: 824

Answers (1)

vtortola
vtortola

Reputation: 35965

That is no problem, the problem is if either server or client try to send a message when there is another message being transmitted. For example if the server sends a partial text frame, and tries to send also a binary frame for video, the browser will show that error, because will try to read the video frame as text. Only control frames can be interleaved between message frames. Rest of messages must be sent one after the other.

Upvotes: 1

Related Questions