Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a list of error codes for WebSocket from the Node.JS ws package?

I’m writing a simple application with Node that connects to a WebSocket server and retrieve’s some information on a set interval. The application needs to be able to handle the possibility of different errors arising from the WebSocket. When I attach a listener to the error event of the socket, the following is an example of the error object that the application receives:

{
  errno: -4073,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '<Server's IP Address>',
  port: <Port #>
}

This is fine. I understand what all of this means. The host is unreachable (which is true, the machine it was tested on has no network connection).

My issue comes with interpreting other errors. I would like to properly handle and report on each error code, like ECONNREFUSED or ECONNRESET and log them to console with some description that makes sense. I would like to find a list of these ECONN errors so I can implement proper handling for the ones I know are most likely to occur.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have Googled and Googled, looked at READMEs, searched for keywords with different packages, generic terms, specific terms, I even tried quoting that specific error code number -4073 and I can’t find anything. I have done a global search of my node_modules for some of these keywords and can’t find anything. Can someone please point me to a list of where these specific error messages can be found?

>Solution :

Those errors are defined in the Standard C library, they aren’t Node’s stuff.
Start here: errno(3) — Linux manual page

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading