Hi!
I'm using Ubuntu and Mosquitto 1.4.10 and can't make the Mosquitto start on boot.
I can see it working when type "mosquitto" on terminal.
But it doesn't work after the reboot.
I did some attempts, the first was:
root@MQTT-Server:~# sudo service mosquitto start Failed to start mosquitto.service: Unit mosquitto.service not found. root@MQTT-Server:~# sudo /etc/init.d/mosquitto start sudo: /etc/init.d/mosquitto: command not found
So I have created a cron tab according to this tutorial like this:
/etc/systemd/system/mosquitto.service
[Unit] Description=Mosquitto MQTT Broker daemon ConditionPathExists=/etc/mosquitto/mosquitto.conf After=network.target Requires=network.target [Service] Type=forking RemainAfterExit=no StartLimitInterval=0 PIDFile=/var/run/mosquitto.pid ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=2 [Install] WantedBy=multi-user.target
Then:
root@MQTT-Server:~# systemctl daemon-reload
The results are:
root@MQTT-Server:~# sudo service mosquitto start Job for mosquitto.service failed because the control process exited with error code. See "systemctl status mosquitto.service" and "journalctl -xe" for details. root@MQTT-Server:~# systemctl status mosquitto.service mosquitto.service - Mosquitto MQTT Broker daemon Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Tue 2016-11-08 19:35:21 UTC; 1s ago Process: 2429 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d (code=exited, status=203/EXEC) Nov 08 19:35:21 MQTT-Server systemd[1]: mosquitto.service: Control process exited, code=exited status=203 Nov 08 19:35:21 MQTT-Server systemd[1]: Failed to start Mosquitto MQTT Broker daemon. Nov 08 19:35:21 MQTT-Server systemd[1]: mosquitto.service: Unit entered failed state. Nov 08 19:35:21 MQTT-Server systemd[1]: mosquitto.service: Failed with result 'exit-code'.
So no luck, any suggestion to solve this problem?
Thanks in advance!
The solution is:
sudo update-rc.d mosquitto remove
sudo nano /etc/systemd/system/mosquitto.service
Paste and save this script
[Unit]
Description=Mosquitto MQTT Broker
Documentation=man:mosquitto(8)
Documentation=man:mosquitto.conf(5)
ConditionPathExists=/etc/mosquitto/mosquitto.conf
After=xdk-daemon.service
[Service]
ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ExecReload=/bin/kill -HUP $MAINPID
User=mosquitto
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl enable mosquitto.service
sudo reboot
check if mosquitto is running
sudo mosquitto -v
I used the above config you wrote FernandoGarcia. I also applied all the commands but I am getting this error message. Anyone can help me?
mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2016-12-02 12:05:28 UTC; 9s ago
Docs: man:mosquitto(8)
man:mosquitto.conf(5)
Process: 512 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=203/EXEC)
Main PID: 512 (code=exited, status=203/EXEC)
This commands worked to me with Ubuntu 16.10.
What's the version of your OS @Lennyz1988?
FernandoGarcia thanks. mosquitto reboot problem is solved. now problem "protocol websockets" not working.
I am running a version based on Debian 8. It's an ARM device from C.H.I.P.. I tried various scripts for autostarting Mosquitto, but I cannot get it to work.
@electrocoder Are you following Shane's tutorial on Youtube?
@Lennyz1988 I don't know this OS but for Ubuntu 14.04 it worked to me:
https://gist.githubusercontent.com/DaveThw/4396124291bb4f92b427
@FernandoGarcia
Still thanks for the help. After many hours I finally got it to work. The paths were different for me and I tried to run it as a daemon.
[Unit]
Description=Mosquitto MQTT Broker daemon
ConditionPathExists=/etc/mosquitto/mosquitto.conf
Requires=network.target
[Service]
Type=simple
ExecStart=/usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
@FernandoGarcia now working websockets.
My os ;
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
now https not running. "load unssafe script" error.
it's link iot mqtt
Look for this tutorial: https://www.youtube.com/watch?v=n3F7auYZqPY
I have it working with websockets
@FernandoGarcia
I watched. The problem has not been solved
Which problem @mesebilisim ?
Websocket SSL problem. Load ca.crt and more certifika and keys but ssl problem on google chrome
Most helpful comment
The solution is:
sudo update-rc.d mosquitto remove
sudo nano /etc/systemd/system/mosquitto.service
Paste and save this script
sudo systemctl enable mosquitto.service
sudo reboot
check if mosquitto is running
sudo mosquitto -v