I'm using nodejs using WebSocket "ws" to connect to another server B.
However, sometimes when the server B is not reachable, mainly "getaddrinfo ENOTFOUND" problem will stop my server, which is not accepted, I should use a try catch to handle the situation and try to connect later.
Where should I put the try catch? It won't trigger the ws.onerror callback.
I've found a similar situation in How to catch getaddrinfo ENOTFOUND
but I've no idea how to use that approach to the ws interface.