MQTT.js icon indicating copy to clipboard operation
MQTT.js copied to clipboard

ws error event can't listener

Open conkyliu opened this issue 3 years ago • 0 comments

I used the wrong host for the ws connection, and found that I could not monitor the "error" event, which made it impossible to determine whether the connection was successful.

However, I printed the client's information and found that socket onxx events are all null. image

image

I added this function, and his message was forwarded before it was accepted successfully this.client.stream.socket.onerror = function (event) { console.error("WebSocket error observed:", event); emiterror(event) }; const emiterror = (e: any) => { this.emit('error', e) } image image

Without the above function, I cannot receive error messages. client.on('error',err=>{}) The built-in on event cannot work.

I think my operation is not the final solution. How do I get the error message?

conkyliu avatar Nov 29 '21 07:11 conkyliu