<html>
<head>
    <title>test Ws mqtt.js</title>
</head>
<body>
    <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script>
    <script>
        var client = mqtt.connect('ws://localhost:8384/mqtt') // you add a ws:// url here
        client.on('connect', function () {
            client.subscribe('/sys/fdcServerApp/Applications.FDC.FdcServerHostApp/thing/event/OnFdcControllerStateChange/post', function (err) {
                if (!err) {
                    client.publish('presence', 'Hello mqtt')
                }
            })
        })

        client.on('message', function (topic, message) {
            // message is Buffer
            console.log(message.toString())
            client.end()
        })
    </script>
</body>
</html>