3

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?

John
  • 43
  • 1
  • 5
  • [Edit](https://stackoverflow.com/posts/61532705/edit) the question to include the full output from when you try to start mosquitto so we can see all the messages and the version of mosquitto you are trying to run. – hardillb May 01 '20 at 07:44

4 Answers4

7

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

Shan-Desai
  • 3,101
  • 3
  • 46
  • 89
  • 1
    thanks, it works for me I'm using Mosquitto v2.0.0. but i get warning that port option is deprecated and will be removed in a future version, so I use listener 1883 instead of port 1883 – poetrasapoetra Jan 26 '21 at 09:22
1

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

John
  • 43
  • 1
  • 5
1

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.

B. Walter
  • 13
  • 1
  • 4
0

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".

guitarpicva
  • 432
  • 3
  • 10
  • Another option is to bind the standard 1883 port to only 127.0.0.1. That's another way to keep it as close hold as possible. If you are using an ACL or certificates for SSL, that would provide more coverage. – guitarpicva Oct 30 '20 at 12:36