Answer the question
In order to leave comments, you need to log in
Node.js websocket, OnClose event doesn't fire, which lib should I use?
https://github.com/websockets/ws
Installed npm package.
The open and message events work fine.
When turning off the Internet, I waited about 5 minutes, but the OnClose event did not appear.
It became a reasonable question:
to make ping-pong commands that interrogate a web socket or change a lib or an interval of more than 5 minutes.
Answer the question
In order to leave comments, you need to log in
So it will be with any one, the normal closing of the socket is a special code (or an error code), when the connection is broken, there is no such code and you can find out that the connection is closed only when you try to send something to it, while ws normally throws an event
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question