Controlling things via the gateway using websockets

Hi,
I’ve been able to use REST to control things via the gateway and am currently trying to do the same with websockets because I’d like the bi-directional communication websockets enables.

new WebSocket(“wss://xxx.mozilla-iot.org/things/http—w25.local-things-led”, “webthing”);

this connects but almost immediately disconnects with a 1005 (no status code was provided) error.

Are there any examples of using websockets to control things via the gateway?

TIA

The biggest thing to know with the gateway is that you have to pass the JWT as a URL parameter when using the gateway, e.g. new WebSocket('wss://xxx.mozilla-iot.org/things/http—w25.local-things-led?jwt=<your jwt>');

The JWT can be your OAuth token or your user token.

1 Like

Thank you, connected and controlling the led thing :slight_smile: