eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.14k stars 468 forks source link

How to catch connect websocket error #113

Closed DieterGehring closed 6 years ago

DieterGehring commented 6 years ago

I wonder if / how i can catch a websocket error during connection. Browsers shows me a WebSocket-Error when connection to a wrong host for instance. But how can I handle this in code?

jpwsutton commented 6 years ago

In your connectOptions, you can add an onFailure callback which will handle this: https://www.eclipse.org/paho/files/jsdoc/Paho.MQTT.Client.html