My node server app is using the ws WebSocket library:
socket.send(data, err => {
if (err == null) {...success...}
else {...failure...}
The client listens for the message also using ws:
ws.on('message', message => ...handler...);
I'm hunting down a bug where sometimes, if the client's network connection is lost (e.g. I turn wifi off) then it looks like the server reports that a message has been successfully sent but the client's handler never got invoked.
QUESTION: is this possible? is this indeed one of the expected failure modes of the 'ws' WebSocket library? What does success from socket.send() actually prove?
(I know that all network protocols have windows of vulnerability in them somewhere. I'm trying to put my finger on where precisely that window is for the ws library so I can build the right semantics on top of it. I haven't yet found from the docs where exactly that window is for ws.)
MAYBE: maybe socket.send reports success once it has placed the message in its outgoing TCP buffer. But then if the network goes down before it has exited the TCP buffer, the message will be lost forever.
MAYBE: maybe socket.send reports success once it has delivered the message into the recipient's TCP message queue and received a TCP ACK confirming that it has been delivered, but then if the client's network goes down before the handler has been invoked then the message will be lost forever.