ASP.NET development note: getting detailed error information from a JavaScript WebSocket object’s “onerror” event is not allowed by the WebSocket specification
Posted: (EET/GMT+2)
If you are using ASP.NET to web sockets and using JavaScript or TypeScript to write client applications, you might have noticed that sometimes it is difficult to get detailed error information using the "onerror" event handler.
However, this is exactly by web socket specification. This is what the specification document says:
"User agents must not convey any failure information to scripts in a way that would allow a script to distinguish the following…"
Thus, in the "onerror" event of the JavaScript, you can merely get a broad error object, but not detailed information. This is to prevent malicious scanning software for being written, for example.
On the other hand, the Web Developer Tools ("F12 tools") in web browsers display more detailed information. For example, Internet Explorer 10 shows the actual reason, such as the SSL/TLS certificate being invalid.
Hope this helps!