eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.92k stars 2.37k forks source link

The Mosquitto Broker Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs #439

Open AndroidDesigner opened 7 years ago

AndroidDesigner commented 7 years ago

hi all. I have installed mosquitto in my PC (windows 10) and it was working well. then i changed mosquitto.conf file to activate username/password authentication. then I wanted to restart the mosquitto service on the PC. but it gives me the following error:

"The Mosquitto Broker Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs"

Now, my mosquitto can not be started again and I have to re-install it whenever I receive this error message. please help me...

ralight commented 7 years ago

The only thing I can think is that there is a problem in your config file that is causing the broker to stop. What if you try to start the broker manually from the command line using the same config file?

vishuPPatel commented 7 years ago

that's same problem for me...!!!

Friend's Give the Solution.....

ericGTT commented 6 years ago

I had this problem. It was because it couldn't open the log file. Delete your log file and restart or just remove the log file from your config file so it's not logging.

PierreF commented 6 years ago

Do you still had this issue ? Had you tried removing the log file as @ericGTT suggested ?

safalya84 commented 6 years ago
  1. I'm facing a similar issue ... removing the log file and then restarting, didn't work for me.
  2. My guess is; it's related to the services. 3a. I can't start the service. 3b. Thought of increasing the log size from event viewer ... but how? if there isn't a file.
    1. What is surprising is.... a month back the exact same settings(No Changes) were working perfectly.
  3. Have attached a few screen shots for reference.

mosquitto_broker_service_not_starting

mosquitto_sub_sctively_refused

vishuPPatel commented 6 years ago

why mosquitto server is Automatically stop?? Active: active (exited) since Tue 2018-04-03 04:59:29 UTC; 7h ago Thanks!!...

nygma2004 commented 6 years ago

I have the same issue. When I just run mosquitto.exe from the command prompt it works OK. When I start the service same issue as described above. I checked my settings file, and nothing is enabled for logging. I could not see any log files created, so there was nothing to delete. For me creating the Windows service (mosquitto.exe install) only worked when I ran Command Prompt as administrator.

EricQ47 commented 6 years ago

Folks encountering this issue:

The problem is with the path to the file(s) set in the config file when running as a service. Apparently mosquitto is pretty picky about parsing the path. I tried a number of quoting and escaping formats to get around the spaces in "Program Files" but in the end I had to move my password file (assume the same would be true with a log file) to the root.

Hope this helps and if anyone does find an acceptable way to reference files in the default install directory, please reply back.

themalakarraja commented 5 years ago
  1. I'm facing a similar issue ... removing the log file and then restarting, didn't work for me.
  2. My guess is; it's related to the services. 3a. I can't start the service. 3b. Thought of increasing the log size from event viewer ... but how? if there isn't a file.
  3. What is surprising is.... a month back the exact same settings(No Changes) were working perfectly.
  4. Have attached a few screen shots for reference.

mosquitto_broker_service_not_starting

mosquitto_sub_sctively_refused

Same problem with me. I restarted PC, then it solved

scoutdriver73 commented 5 years ago

Folks encountering this issue:

The problem is with the path to the file(s) set in the config file when running as a service. Apparently mosquitto is pretty picky about parsing the path. I tried a number of quoting and escaping formats to get around the spaces in "Program Files" but in the end I had to move my password file (assume the same would be true with a log file) to the root.

Hope this helps and if anyone does find an acceptable way to reference files in the default install directory, please reply back.

Thanks for the tip of what to look for. I managed to reference the password file as follows: "password_file C:\Progra~1\mosquitto\passwd" No quotes in the configuration file. Hope that helps someone out.

Shivaratn commented 4 years ago

I had this problem. It was because it couldn't open the log file. Delete your log file and restart or just remove the log file from your config file so it's not logging.

where is this log file located?

ericGTT commented 4 years ago

Look in the config file and see where it's saved to.

engixx commented 4 years ago

Using full paths, limiting folder name character count worked for me:

log_dest file C:\Progra~1\mosquitto\mosquitto.log
password_file C:\Progra~1\mosquitto\user_security

Log file was also an issue, even when trying to open it afterwards. Reason being that the service account in which the broker is running is the owner of the log file, thus preventing even an Admin account from opening it.

bagadonitz commented 4 years ago

Glad I found this thread. For anyone else, having the full path on any files referenced in the mosquitto.conf worked for me, even if the files were in the same directory.

Now does anyone have a fix for the log issue? I can not find a way to open this log file. What good is a log file if you can't view it?

EddieGreen commented 4 years ago

You have to provide the appropriate permissions to the logon for the service.

If the service is running under the local system account, then add LOCAL SERVICE to the permissions for the installation folder.

Alternatively, change the service logon to another account and make sure permissions are set accordingly for the folder.

image

ErixWong commented 4 years ago

For me, the reason is, had extra double quotes in password file define. Wrong: password_file "C:\Program Files\mosquitto\passwd.txt" Right: password_file C:\Program Files\mosquitto\passwd.txt

kiwibirdegg commented 2 years ago

For me, the reason is, had extra double quotes in password file define. Wrong: password_file "C:\Program Files\mosquitto\passwd.txt" Right: password_file C:\Program Files\mosquitto\passwd.txt

This solution worked for me. As someone who works with PowerShell, I am used to double quoting Program Files to avoid the issue caused by having space in between Program and Files. In my config file, I changed my path from C:\ "Program Files"\mosquitto\passwd.txt to C:\Program Files\mosquitto\passwd.txt

Worked for me. Thanks @ErixWong !

xiaoyuvax commented 2 years ago

Worked for me! thanks! Next ver of Mosquitto should be improved to adopt MOSQUITTO_DIR env var to solve this problem.

cholme690 commented 11 months ago

My problem was it couldn't open the password file no matter where i put it. Not even when it was in root. I fixed the problem by giving System full control of the file rather than just my user.

briantho commented 10 months ago

My problem was it couldn't open the password file no matter where i put it. Not even when it was in root. I fixed the problem by giving System full control of the file rather than just my user.

Thanks. I was facing the exact same problem. No matter where i put the passwd file, i couldn't get the service running. It of course worked when I ran via CLI, but the service just would not run. changed permissions to allow "SYSTEM" full control, and bam, now it's running. Thanks

umitliguler commented 5 months ago

You have to provide the appropriate permissions to the logon for the service.

If the service is running under the local system account, then add LOCAL SERVICE to the permissions for the installation folder.

Alternatively, change the service logon to another account and make sure permissions are set accordingly for the folder.

image

it work for password file not only mosquitto folder :)

AltPio commented 4 months ago

Check if Notepad sometimes adds a .txt extension when you edit the mosquitto.conf file. You can see this only after setting File Manager to show file extensions. If you see .txt remove it and leave only .conf It's a simple mistake, but that's exactly how Windows 11 reacted as you described, by automatically closing Mosquitto and displaying an error message. Best regards.

israelz330 commented 3 months ago

I was able to fix this issue by just adding the 'passwordfile' directly at C:\passwordfile and then I added these 2 lines to the mosquitto.conf:

allow_anonymous false password_file C:\passwordfile

If I change the location of the file it will not work...

varoblanco commented 1 week ago

OMFG more than 2 days with this and this worked perect