Cannot run the MQTT Broker Service

69 Views Asked by At

At first, when i set the

listener 1883
allow_anonymous true

in mosquitto.conf, i can run the mqtt broker service by "net start mosquitto" in CMD and it worked when i checked the services. But when I change it into

listener 1883
allow_anonymous false
password_file C:\Program Files\mosquitto\passwd

I cannot run the mqtt broker anymore athough in CMD it has successfully. When I tried to run mqtt broker directly on servicecs, it said

The Mosquitto Broker service on Local Storage started and then stopped. Some services stop automatically if they are not in use by other services or programs

I have tried to reinstall it so many times and I still get this error.

1

There are 1 best solutions below

1
hardillb On

You can always test your config file by explicitly running it from the command line with

mosquitto -c c:\full\path\to\mosquitto.conf

You should stop the service first so as not to clash on the port used.

In this case it would likely have printed an error about being unable to find the password file because it has a space in the path. You should be able to fix this by wrapping it in quotes:

listener 1883
allow_anonymous false
password_file "C:\Program Files\mosquitto\passwd"