FROST-Server Documentation

Live documentation for the development version.

Using MQTT from JavaScript

To facilitate your start with FROST and MQTT, we provide a short abstract about how to subscribe to FROST via MQTT.

In the following, we use Eclipse Paho as an MQTT client and a FROST server as MQTT broker.


  1. Require Paho from your trusted cdn, such as:

    <script src="" type="text/javascript"></script>

  2. In your JS, create a new Paho Client (find the blue print for the instanciation of a Paho Client here) and give it appropriate callback handlers

     let pahoConfig = {
             hostname: "localhost",  //The hostname is the url, under which your FROST-Server resides.
             port: "9876",           //The port number is the WebSocket-Port,
                                     // not (!) the MQTT-Port. This is a Paho characteristic.
             clientId: "ClientId"    //Should be unique for every of your client connections.
     client = new Paho.Client(pahoConfig.hostname, Number(pahoConfig.port), pahoConfig.clientId);
     client.onConnectionLost = onConnectionLost;
     client.onMessageArrived = onMessageArrived;
         onSuccess: onConnect
     function onConnect() {
     // Once a connection has been made, make a subscription and send a message.
     console.log("Connected with Server");
     function onConnectionLost(responseObject) {
         if (responseObject.errorCode !== 0) {
             console.log("onConnectionLost:" + responseObject.errorMessage);
     function onMessageArrived(message) {
         console.log("onMessageArrived:" + message.payloadString);
         let j = JSON.parse(message.payloadString);
  3. Do something with your received message

     function handleMessage(message) {
         if (message != null && message != undefined) {