可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
回答1:
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
回答2:
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
回答3:
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