Closed FernandoGarcia closed 8 years ago
Connection refused means the service you're trying to access (localhost/1883) isn't listening (not started) or is being actively blocked by a firewall. I think you're experiments are in the wrong order: judging by your logs, Mosquitto is running so I think your publish occurred during a moment when Mosquitto wasn't (yet) running.
Thanks for fast reply!
I did:
sudo ufw allow 1883
and a reboot I have checked the firewall and it's opened.
After the result is equal.
Typing "mosquitto" on terminal I can see it working, there
1478619266: mosquitto version 1.4.10 (build date 2016-11-06 20:16:49+0000) starting 1478619266: Using default config. 1478619266: Opening ipv4 listen socket on port 1883. 1478619266: Opening ipv6 listen socket on port 1883. 1478619268: New connection from 189.40.46.60 on port 1883. 1478619268: New client connected from 189.40.x.x as M-001 (c1, k15, u'fernandogarcia').
This client (M-001) connected is an ESP12 that I have running a test code here.
Publishing something on terminal
1478619422: New connection from 127.0.0.1 on port 1883. 1478619422: New client connected from 127.0.0.1 as mosqpub/1983-MQTT-Serve (c1, k60, u'fernandogarcia'). 1478619422: Client mosqpub/1983-MQTT-Serve disconnected.
So it's working but after type ctrl +c on terminal it doesn't works anymore.
Therefore the Mosquitto is not running continuously I think, how I can solve it?
By hitting CTRL-C you are killing your Mosquitto instance. I assume you want to have it started at boot. (Look for something like service start mosquitto or systemctrl enable mosquitto -- this depends on your distribution.
On Tue, 8 Nov 2016 at 16:43, Fernando Garcia notifications@github.com wrote:
Thanks for fast reply!
I did:
sudo ufw allow 1883
and a reboot I have checked the firewall and it's opened.
After the result is equal.
Typing "mosquitto" on terminal I can see it working, there
1478619266: mosquitto version 1.4.10 (build date 2016-11-06 20:16:49+0000) starting 1478619266: Using default config. 1478619266: Opening ipv4 listen socket on port 1883. 1478619266: Opening ipv6 listen socket on port 1883. 1478619268: New connection from 189.40.46.60 on port 1883. 1478619268: New client connected from 189.40.x.x as M-001 (c1, k15, u'fernandogarcia').
This client (M-001) connected is an ESP12 that I have running a test code here.
Publishing something on terminal
1478619422: New connection from 127.0.0.1 on port 1883. 1478619422: New client connected from 127.0.0.1 as mosqpub/1983-MQTT-Serve (c1, k60, u'fernandogarcia'). 1478619422: Client mosqpub/1983-MQTT-Serve disconnected.
So it's working but after type ctrl +c on terminal it doesn't works anymore.
Therefore the Mosquitto is not running continuously I think, how I can solve it?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/jpmens/mosquitto-auth-plug/issues/173#issuecomment-259171625, or mute the thread https://github.com/notifications/unsubscribe-auth/AADtIjiWNN79H9-pR7QHE1FKz7p41n72ks5q8JiUgaJpZM4Kshvu .
I'm using Ubuntu.
I think that Mosquitto service doesn't exist here.
The result are:
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?
Hi!
This commands should solved this problem.
sudo update-rc.d mosquitto remove sudo git clone https://github.com/Dan-in-CA/mosquitto_unit_file.git sudo cp mosquitto_unit_file/mosquitto.service /etc/systemd/system/mosquitto.service sudo systemctl enable mosquitto.service sudo reboot
check if mosquitto is running
sudo mosquitto -v
Thanks for your time.
Best regards.
I had errors with this script.
This one worked fine:
[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
Hi!
Firstly, thanks for this plugin!
I would like to know the reason to a refused connection but I can't find an error log for it.
I'm trying to publish and subscribe using the terminal and the result is like this:
My mosquitto.conf is like this:
Running this command:
The result is:
Using verbose mode (mosquitto -v) in a terminal I have this:
In another:
Can someone give me a suggestion about where to look to find the error? How can I enable the error log?
Thanks in advance.