Mosquitto Websockets Not Really Started

I added the following to the mosquitto add-on in hassio:
“customize”: {
“active”: true,
“folder”: “mosquitto”
},

in /share I have a mosquitto directory with a conf file that contains:
listener 8080
protocol websockets

When I restart the mosquitto add-on it reports:
starting version 3.2.2
1509573381: mosquitto version 1.4.12 (build date 2017-06-01 13:03:46+0000) starting
1509573381: Config loaded from /etc/mosquitto.conf.
1509573381: Opening websockets listen socket on port 8080.
1509573381: Opening ipv4 listen socket on port 1883.
1509573381: Opening ipv6 listen socket on port 1883.

Looks like websockets is started, but, when I try to use HiveMQ to access 8080 I get errors (it works OK for some test sites).

And, netstat reports:
jeff@xHass:~$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.100:445 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.100:139 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN
tcp 0 0 192.168.0.100:8300 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::1883 :::* LISTEN
tcp6 0 0 :::5355 :::* LISTEN
tcp6 0 0 :::8883 :::* LISTEN
jeff@xHass:~$

1883 shows up, but not 8080.

Any ideas would be appreciated.

Nobody can help me?

You’ll have to modify config.json for the addon to forward the websocket ports to the container as well as modify mosquitto.conf file to enable websockets. You could do that by creating a local addon using instructions at https://home-assistant.io/developers/hassio/addon_development/ and the addon config from https://github.com/home-assistant/hassio-addons/tree/master/mosquitto.

Excellent. Works great. Thank you!

… ok … for the noob? someone help me posting more detailed instructions?

I’m very much interested in activating a listener with websockets to using mosquitto broker. The embedded broker should support it but can’t really get it to work at all.
Could you please give some more detailed instructions on what exactly needs to be done? It would be much appreciated!!

The add-on broker was not compiled with websockets support, so you can configure all day to no avail.

I followed the instructions provided by NotoriousBDG and have a local add-on that supports websockets. Have you tried to follow those instructions?

If so, do you have a specific problem with which you need help?

If you do not understand those instructions enough to attempt the process, then more detail will be time consuming to produce, and still may not help.

Instead, I will endeavor to make my version available as a community supported add-on or as an additional repository add-on. Either way you will install a different mosquitto add-on and then configure it for websockets.

I’ve not done this before, so I’ll let you know when I have accomplished one or the other.

Sorry. Two corrections.

  1. It’s a config.json issue, not a compile issue.

  2. I decided it is faster for me to explain how to do it yourself. Here goes:

  3. At https://github.com/home-assistant/hassio-addons use the “Clone or Download” button to get a zip file. Expand it to obtain the mosquitto folder. Should contain five files.

  4. Edt “config.json”. Revise ports as follows and save:
    “ports”: {
    “1883/tcp”: 1883,
    “8883/tcp”: 8883,
    “8080/tcp”: 8080
    },

  5. Install Samba Share add-on. Copy revised mosquitto folder to addons folder on hass.io.

  6. In share folder on hass.io create a mosquitto folder and in it create “enable_websockets.conf” as follows:
    listener 8080
    protocol websockets
    log_type websockets
    websockets_log_level 255

  7. restart hass.io. Access your Hass.io > ADD-ON STORE. In Local add-ons find your Mosquitto broker. Open it, and install it.

  8. Edit and save the config to include:
    “customize”: {
    “active”: true,
    “folder”: “mosquitto”
    },

  9. Restart MQTT add-on.

  10. get HiveMQ websockets client from https://www.hivemq.com/downloads/

  11. enjoy.

2 Likes