1

I have an ionic angular app where i am using websocket client to communicate with server. It is failing and I am unable to get the error details for the failures. the code looks like below

 ws.addEventListener('error', (event:any) => {
      console.error("The socket had an error", event);
      alert('event is:' + event.message)
      this.messageQueue.presentToast("Error connecting to chat server",false,0)
    });

the event.message is undefined. So how do i find what exact error is coming here?

Vik
  • 8,721
  • 27
  • 83
  • 168
  • Possible duplicate of [Websocket onerror - how to read error description?](https://stackoverflow.com/questions/18803971/websocket-onerror-how-to-read-error-description) – Randy Casburn Apr 04 '18 at 03:39
  • checked that. i do not hit close event. I am hitting error event only. so need to get details in the error function – Vik Apr 04 '18 at 03:48
  • You don't, but the protocol does. Anytime an error condition occurs, the connection is closed. The corresponding simple error is sent under this condition - just as the other reference discusses. – Randy Casburn Apr 04 '18 at 03:58
  • 1
    not happening in my case. i dont see connection closed at all – Vik Apr 04 '18 at 06:07

0 Answers0