-1

Do Websockets have a mechanism to handle lost data, by default?

Oversimplifying here, say I send 3 packages from server (node.js) to client (vue js). Package number 2 is lost.

Is there a way to resend it or at least notify the client with an error? Or the WS does not support something like that at all because of its stream nature?

Even if WS do not support it, is there a node module that does?

Thanks

codebot
  • 517
  • 8
  • 29
  • 55

1 Answers1

1

Websocket per-se as a protocol doesn't manage "lost" data. It's a full duplex TCP (not UDP where delivery is not guaranteed) so usually you either receive the whole message or nothing, the nothing case is the one you need to account for yourself, unfortunately.

The good news is that there are quite a few middleware for node.js you can use, IE socket.io, which have tons of business-logic implemented for you, like reconnect, ping-pong, ack/syn, long polling etc...

Dado
  • 1,147
  • 1
  • 13
  • 31