S
S
Sergey Veselov2018-11-26 21:17:37
JavaScript
Sergey Veselov, 2018-11-26 21:17:37

How to get the sending status of a message via WebSocket?

Server:

  • Node.js v10
  • express ws
  • Set event handlers: message, error, close
Customer:
  • Google Chrome
  • window.WebSocket
  • Set event handlers: open, message, error, close
  • ws.send(Msg) wrapped by try catch
Problem:
A connection is always established, messages go from the client to the server, where they are processed and sent to the client, and the client receives a response from the server. But sometimes it happens that after calling ws.send (with a message) on the client, nothing comes to the server. On the client (try catch does not catch any errors) and on the server there is no reaction to the sent data from the client.
How to get the sending status of a message via WebSocket? Or how to understand that the message is completely sent to the server?
-----
With the inspector open, the problem is much less.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2018-11-26
@bingo347

in general, the websocket eventually works on top of tcp, which itself notifies the other side about the delivery of the packet, and if the notification is not received, after a while the packet is sent again
, the websocket itself does not have such a built-in mechanism, but no one bothers to implement this yourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question