eclipse / paho.mqtt.javascript

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

No implicit global WebSocket #194

Closed markevans-sky closed 5 years ago

markevans-sky commented 5 years ago

Hi there - I'm using Paho to connect to MQTT via websocket in an environment which is a modified version of Node.js.

It was causing an error "ReferenceError: WebSocket is not defined" due to the line https://github.com/eclipse/paho.mqtt.javascript/blob/develop/src/paho-mqtt.js#L1054, which contains

  new WebSocket(...)

Changing this to

  new global.WebSocket(...)

fixes the problem.