'Mosquitto Broker service refuses to start on websockets

I am trying to start my Eclipse Mosquitto broker service for listening to websockets adding:

listener 8083
protocol websockets

at the mosquitto.conf

If I only use listener 8083, the service starts but when protocol websockets is added, the service stops and refuses to start.

The error I get if I run:

mosquitto -v -c mosquitto.conf

is: 1588309602: Error: Unable to start any listening sockets, exiting.

The full output is:

1588309602: mosquitto version 1.6.9 starting
1588309602: Config loaded from mosquitto.conf.
1588309602: Opening websockets listen socket on port 8083.
1588309602: Error: Unable to start any listening sockets, exiting.

I am under Windows10 Pro.

Any ideas?



Solution 1:[1]

The answer to this:

Based on trials I can confirm that you need to mention a default port initially e.g.


port 1883
protocol mqtt


# Websockets

listener 9001
protocol websockets

if you only wish to use WebSockets for MQTT then instead of using listener 9001 you need to replace it with port 9001.

There should be atleast one default port to listen to in Mosquitto MQTT.

Verified using Mosquitto 1.6.10

Solution 2:[2]

I am posting an answer based on facts. I have uninstalled version 1.6.9 and installed 1.6.7 and now the service is running using websockets...

I cannot confirm if this is an issue with 1.6.9 but this is what happened to me.

BR

Solution 3:[3]

According to other sources, the error lies in 1.6.10 (and perhaps others), whereby, there MUST be a standard protocol mqtt defined, otherwise websockets will not start.

Thus you can leave the standard configuration alone (port 1883) and then in the Extra listeners section of mosquitto.conf, define the websockets listener as you like.

I believe this has been remedied in later versions, so that only websockets can be defined.

Sadly, in this case the only defense against unauthorized use of the broker over the standard mqtt socket is then the system firewall for external users. Users with ssh access can "play".

Solution 4:[4]

The mqtt protocol has to be enabled for the websockets to work. As the option port (like others have mentioned) is deprecated in versions 2.x.x, you can use listener instead.

listener 1883
protocol mqtt

listener 9001
protocol websockets

And then run your mosquitto server as usual.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shan-Desai
Solution 2 John
Solution 3 guitarpicva
Solution 4 B. Walter