Mosquitto 1.4.2 Websocket support

2019-02-19 10:43发布

I'm trying to utilize Mosquittos recent update to support websockets in the broker. I'm running Mosquitto v1.4.2 and I've added the following lines to the mosquitto configuration file (mosquitto.conf):

listener 10001 127.0.0.1
protocol websockets

listener 1883
protocol mqtt

When I try and start the broker with the new configuration I get the following :

$ mosquitto -c /etc/mosquitto/mosquitto.conf
Error: Websockets support not available.
Error found at /etc/mosquitto/mosquitto.conf:16.
Error: Unable to open configuration file.

I was under the assumption that version 1.4 and above of Mosquitto has websocket support now (don't have to build from source to enable websocket support like you had to before v1.4) so I'm wondering what I'm missing. Any help on what direction to look to troubleshoot the problem is appreciated.

Edit: Forgot to mention I'm running CentOS6

3条回答
叛逆
2楼-- · 2019-02-19 10:59

While the 1.4.x codebase includes Websocket support it has to be enabled at build time and relies on the libwebsocket library.

The builds currently available in the RedHat/Fedora yum repos do not have Webosockets enabled as there is no libwebsocket package available. I assume CentOS is using the same srpms.

See this bugzilla enrty for details: https://bugzilla.redhat.com/show_bug.cgi?id=1197678

查看更多
成全新的幸福
3楼-- · 2019-02-19 11:04

In the dir mosquitto-1.4.X edit the file config.mk:

# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes

Then run in the dir mosquitto-1.4.X

make
sudo make install

Edit the configurations /etc/mosquitto/mosquitto.conf

listener 10001 127.0.0.1
protcol websockets

And restart

mosquitto -c /etc/mosquitto/mosquitto.conf
查看更多
何必那么认真
4楼-- · 2019-02-19 11:12

you can modify config.mk like this

in config.mk

# Build with websockets support on the broker.
WITH_WEBSOCKETS:=yes

then can you use a config parameter

listener 10001 127.0.0.1
protocol websockets
查看更多
登录 后发表回答