ws2mqtt

A WebSocket proxy to an MQTT broker backend.

Usage no npm install needed!

<script type="module">
  import ws2mqtt from 'https://cdn.skypack.dev/ws2mqtt';
</script>

README

ws2mqtt

A WebSocket proxy to an MQTT broker backend.

Install the CLI

npm install -g ws2mqtt

Usage

Run a WebSocket server that proxies messages to an MQTT broker.

ws2mqtt [-h <websocket-host>] [-p <websocket-port>] [-c <mqtt-broker-url>]
[--debug]

Options:
      --help     Show help                                             [boolean]
      --version  Show version number                                   [boolean]
  -h, --host     WebSocket server host           [string] [default: "localhost"]
  -p, --port     WebSocket server port                  [number] [default: 3000]
  -c, --broker   Connection URL to an MQTT broker
                                     [string] [default: "mqtt://localhost:1883"]
  -d, --debug    Print debug info                     [boolean] [default: false]

Once the proxy is running, connect to the WebSocket server using the following URL format:

http://{host}:{port}/{+topic}{?action}

Where host and port reference the values used when starting the proxy, topic matches the MQTT topic (e.g., myhome/temperature), and the action query string parameter equals publish or subscribe.

Test your proxy with the WebSocket Proxy to MQTT Broker Postman collection!

License

MIT