Mosquito error address already in use

I am running a Mosquitto install on a Debian 9 LXC container (hosted by a Proxmox server). When I run the command "sudo service mosquitto restart" the broker is not restarted successfully...

@begleysm

I am running a Mosquitto install on a Debian 9 LXC container (hosted by a Proxmox server).

When I run the command «sudo service mosquitto restart» the broker is not restarted successfully. I get the error «Error: Address already in use».

user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto restart
[sudo] password for user: 
user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto status 
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (exited) since Tue 2019-01-22 20:19:23 EST; 30s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 31328 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 31333 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)

Jan 22 20:19:23 server systemd[1]: Stopped LSB: mosquitto MQTT v3.1 message broker.
Jan 22 20:19:23 server systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Jan 22 20:19:23 server mosquitto[31333]: Starting network daemon:: mosquitto.
Jan 22 20:19:23 server systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
Jan 22 20:19:23 server mosquitto[31338]: mosquitto version 1.5.4 starting
Jan 22 20:19:23 server mosquitto[31338]: Config loaded from /etc/mosquitto/mosquitto.conf.
Jan 22 20:19:23 server mosquitto[31338]: Opening ipv6 listen socket on port 1883.
Jan 22 20:19:23 server mosquitto[31338]: Error: Address already in use
Jan 22 20:19:23 server mosquitto[96]: mosquitto version 1.5.4 terminating
Jan 22 20:19:23 server mosquitto[96]: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.

However when I run «sudo service mosquitto stop» followed by «sudo service mosquitto start» things work fine.

user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto stop
user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto status
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: inactive (dead) since Tue 2019-01-22 20:30:57 EST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 31431 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 31398 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/mosquitto.service

Jan 22 20:20:22 server mosquitto[31403]: Socket error on client <unknown>, disconnecting.
Jan 22 20:20:39 server mosquitto[31403]: New connection from 1.2.3.4 on port 8883.
Jan 22 20:20:46 server mosquitto[31403]: Socket error on client brokeruser1, disconnecting.
Jan 22 20:20:46 server mosquitto[31403]: New client connected from 1.2.3.4 as brokeruser1 (c0, k3600, u'broker').
Jan 22 20:21:03 server mosquitto[31403]: Outgoing messages are being dropped for client brokeruser2.
Jan 22 20:30:57 server systemd[1]: Stopping LSB: mosquitto MQTT v3.1 message broker...
Jan 22 20:30:57 server mosquitto[31431]: Stopping network daemon:: mosquitto.
Jan 22 20:30:57 server systemd[1]: Stopped LSB: mosquitto MQTT v3.1 message broker.
Jan 22 20:30:57 server mosquitto[31403]: mosquitto version 1.5.4 terminating
Jan 22 20:30:57 server mosquitto[31403]: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto start
user@server:/etc/letsencrypt/scp/server.com$ sudo service mosquitto status
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Tue 2019-01-22 20:31:01 EST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 31431 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 31463 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/mosquitto.service
           `-31468 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jan 22 20:31:01 server systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Jan 22 20:31:01 server mosquitto[31463]: Starting network daemon:: mosquitto.
Jan 22 20:31:01 server systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
Jan 22 20:31:01 server mosquitto[31468]: mosquitto version 1.5.4 starting
Jan 22 20:31:01 server mosquitto[31468]: Config loaded from /etc/mosquitto/mosquitto.conf.
Jan 22 20:31:01 server mosquitto[31468]: Opening ipv6 listen socket on port 1883.
Jan 22 20:31:01 server mosquitto[31468]: Opening ipv4 listen socket on port 1883.
Jan 22 20:31:01 server mosquitto[31468]: Opening ipv4 listen socket on port 8883.
Jan 22 20:31:01 server mosquitto[31468]: Opening ipv6 listen socket on port 8883.

What gives? Is the restart command not attempting to release the port? Is it not waiting long enough before it tries to start the server again?

@ralight

Can you give any more details about how you installed this?

@begleysm

I’ve got Proxmox 5.2-12 installed an a Dell R510 Server.

I created a Container using their tool with a Debian 9.3-1 Template.

I updated/upgraded Debian. I then installed Mosquitto from the moquitto.org repository with the following set of commands

    5  sudo curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
    6  sudo apt-key add mosquitto-repo.gpg.key 
    7  cd /etc/apt/sources.list.d/
    8  sudo curl -O http://repo.mosquitto.org/debian/mosquitto-$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release).list
    9  sudo apt-get update
   10  sudo apt-get install mosquitto mosquitto-clients

Thanks for taking some time to look into this issue.

@momoskitto

I have noticed a similar issue on debian. In debian, the mosquitto broker is restarted with the start-stop-daemon. Unfortunately, when stopping the service, it is only sending a signal to mosquitto, not waiting for it to shut down before starting it again, causing the «address already in use» error. I fixed it by adding the «—retry» option to the start-stop-deamon --stop call in /etc/init.d/mosquitto.

@begleysm

Thank you @momoskitto, that makes a lot of sense. That suggests that this really is a bug in the /etc/init.d/mosquitto file provided by Eclipse Mosquitto.

I’ve uploaded my /etc/init.d/mosquitto file here for reference.

For helping my problem. Are saying you added a «—retry» option to the start-stop-daemon --stop call on line 58 or line 84 (or line 72 or line 100) of the attached file? Because the —stop reference on line 84 is for «restart» but it already contains a «—retry 30». The —stop on line 58 is for the «stop» command and does not contain a «—retry» but I wouldn’t think it would be run when calling with «restart». The other two line references are for reload and try-restart.

@momoskitto

I actually didn’t remember all details and my previous answer is unclear, thank you for your follow-up. So I checked again what I did:

I did change the call of the start-stop-daemon for the «stop» command, not «restart». In my case, the problem only occurred in combination with systemd restart mosquitto.service, which does not actually send a «restart» command but rather a «stop» followed by a «start». Therefore it helped to wait for mosquitto to exit after sending the «stop» command.

@begleysm

Thank you. Looking at my original output of sudo service mosquitto restart sudo service mosquitto status it would appear as though my call is also actually running a «stop» followed by a «start» so it is likely your fix will work for me as well. Thank you.

I tried changing line 58 from
if start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE}; then
to
if start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} --retry 30; then
and that appears to have «fixed» the problem allowing «sudo service mosquitto restart» to successfully stop and start the service giving that status output:

user@server:~$ sudo service mosquitto restart
user@server:~$ sudo service mosquitto status
* mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Fri 2019-02-08 11:18:11 EST; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 8159 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 8164 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/mosquitto.service
           `-8169 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Feb 08 11:18:11 server systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Feb 08 11:18:11 server mosquitto[8164]: Starting network daemon:: mosquitto.
Feb 08 11:18:11 server systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
Feb 08 11:18:11 server mosquitto[8169]: mosquitto version 1.5.4 starting
Feb 08 11:18:11 server mosquitto[8169]: Config loaded from /etc/mosquitto/mosquitto.conf.
Feb 08 11:18:11 server mosquitto[8169]: Opening ipv6 listen socket on port 1883.
Feb 08 11:18:11 server mosquitto[8169]: Opening ipv4 listen socket on port 1883.
Feb 08 11:18:11 server mosquitto[8169]: Opening ipv4 listen socket on port 8883.
Feb 08 11:18:11 server mosquitto[8169]: Opening ipv6 listen socket on port 8883.

In regards to fixing this bug:
This seems like something that should be addressed in the Mosquitto package. I think that adding the «—retry» option is more of a quick work around and the correct approach would, ultimately, be to check for those closing of the sockets (although I don’t currently know how to implement that).

@ralight

--retry is a good fallback, thanks for pointing that out, but the better solution would be to use the systemd unit files that the debian official packaging uses. It’s just a mistake that those aren’t installed for the repo.mosquitto.org packages. I’ll see about sorting that out.

@begleysm

Thanks @ralight. It would be great to see this addressed in the package since I suspect that whatever «work around» is implemented will likely be overwritten with an upgrade.

@ralight

I’m closing this because the systemd file is in the latest packages, plus I’ve just now added --retry 30 to the init file as a fallback.

@mmadoo

I have tested the latest ubuntu package that has --retry option and the issue is still present.
If I do:
service mosquitto stop ;service mosquitto start ; sleep 2;service mosquitto status
then it is always OK (it shows active (running))
but the command fails (it shows active (exited))
service mosquitto restart ; sleep 2;service mosquitto status

@lock
lock
bot

locked as resolved and limited conversation to collaborators

Aug 13, 2019

I’m experiencing the same

Address already in use

error.

Mosquitto was running happily on a RPi3B but then traffic suddenly stopped. Not being particularly adept with these technoclogies I attempted to resolve the issue by uninstalling Mosquitto and then reinstalling it.

While the install seemed to go OK the problem was still there. The mqtt broker was no longer apparently operative.

As an example of the log results, after a fresh restart of the Pi he most log shows the following:

Code: Select all

1527229407: mosquitto version 1.5 starting
1527229407: Config loaded from /etc/mosquitto/mosquitto.conf.
1527229407: Opening websockets listen socket on port 9001.
1527229407: Opening ipv4 listen socket on port 1883.
1527229407: Opening ipv6 listen socket on port 1883.
1527229407: Opening ipv4 listen socket on port 1883.
1527229407: Error: Address already in use

The results of a service status query is as follows:

Code: Select all

pi@vistacontroltest:~ $ service mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto)
   Active: active (exited) since Fri 2018-05-25 06:23:27 UTC; 1min 56s ago
  Process: 513 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)

And a peek at what processes named ‘mosquitto’ are running produces:

Code: Select all

pi@vistacontroltest:~ $ ps -ef | grep mosquitto
pi        1529  1387  0 06:25 pts/0    00:00:00 grep --color=auto mosquitto
pi@vistacontroltest:~ $ sudo nano /var/log/mosquitto/mosquitto.log

For good measure I ran the same query on process 1387 that kicked off mosquitto and my lay judgement suggests this appears to the system boot that started it:

Code: Select all

pi@vistacontroltest:~ $ ps -ef | grep 1387
pi        1387  1385  0 06:25 pts/0    00:00:00 -bash
pi        1800  1387  0 06:51 pts/0    00:00:00 ps -ef
pi        1801  1387  0 06:51 pts/0    00:00:00 grep --color=auto 1387

It does not appear that two instances of mosquitto are running so the cause must be another process. Is anyone out there skilled enough to point me in the right direction to resolve what might be going wrong here.

Содержание

  1. Mosquito error address already in use
  2. Re: Mosquito Error:Address already in use
  3. Re: Mosquito Error:Address already in use
  4. Re: Mosquito Error:Address already in use
  5. Re: Mosquito Error:Address already in use
  6. Re: Mosquito Error:Address already in use
  7. Re: Mosquito Error:Address already in use
  8. Re: Mosquito Error:Address already in use
  9. Re: Mosquito Error:Address already in use
  10. Re: Mosquito Error:Address already in use
  11. Re: Mosquito Error:Address already in use
  12. Mosquito error address already in use
  13. Re: mosquitto port 1883 already in use
  14. Re: mosquitto port 1883 already in use
  15. Re: mosquitto port 1883 already in use
  16. Mosquito error address already in use
  17. Re: Mosquito Error:Address already in use
  18. Re: Mosquito Error:Address already in use
  19. Re: Mosquito Error:Address already in use
  20. Re: Mosquito Error:Address already in use
  21. Re: Mosquito Error:Address already in use
  22. Re: Mosquito Error:Address already in use
  23. Re: Mosquito Error:Address already in use
  24. Re: Mosquito Error:Address already in use
  25. Re: Mosquito Error:Address already in use
  26. Re: Mosquito Error:Address already in use
  27. Error: Address already in use #2142
  28. Comments
  29. Error: Address already in use after fresh installation on Debian 9 «Stretch» (most current version, updated with apt-get upgrade) #1768
  30. Comments

Mosquito error address already in use

Mosquitto was running happily on a RPi3B but then traffic suddenly stopped. Not being particularly adept with these technoclogies I attempted to resolve the issue by uninstalling Mosquitto and then reinstalling it.

While the install seemed to go OK the problem was still there. The mqtt broker was no longer apparently operative.

As an example of the log results, after a fresh restart of the Pi he most log shows the following:

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Re: Mosquito Error:Address already in use

Two days ago I decided to update my raspberry PI 3 running debian Jessie. After this update I noticed that a new version of mosquitto was installed, version 1.5 and my web client was not receiving any messages anymore. My client is A simple HTML page using paho javascript client that connects to a server using WebSockets. It all run flawless for half a year now but after the update it stopt working thru websockets. When I connect with a different client to port 1883 I see all my messages and I am able to publlise.

Wat I tried so far is:
— comment out the 1883 in the configuration file and rebooted the mosquitto service
— set allow_anonymous to true
— running a netstat command where I see two listener foor mosquitto port 1883 and 9001

pulling my hear out here for two days now, anybody here with the same problem and solved this?

Re: Mosquito Error:Address already in use

@rorie I also noticed my Mosquitto wasupdated to 1.5 in the last couple of days. I don’t seems to have issues with the websocket. Have you tried enabling all log types, and looking at the mosquittto.log to see if the connection and subscriptions are being accepted from the web client?

Something else I found, if you connect to your website with https, then you need to use secure websockets otherwise browsers complain. I’ll assume this isn’t the case if it was working before 1.5 though.

@dweston in the log from mosquitto looks like its trying to start 2 listeners on the port 1883

Re: Mosquito Error:Address already in use

@MrWhite_2018 Thanks for your reply, which version of Debian are you using, stretch or Jesie? In noticed that sending of a message from the webclient to my broker is working, slower dan normally but ik works.

I am using Jessie at the moment, tonight i will make a backup en try to install stretch to see if this solved the problem.

Re: Mosquito Error:Address already in use

@rorie I have Stretch now. When I first installed mosquitto it installed 1.4.10 which worked fine. along the update path for other items I noticed mosquitto updated to 1.5 but still worked fine.

I had issues with 1.5 with Jessie from the webclient. My connections wouldn’t work at all. The logs showed that something was constantly being sent by the broker, but no idea what. I resolved it by upgrading to Stretch.

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

It appears that I too am running 2 sessions of Mosquitto Broker (ver 1.5.5) on my RPi3 loaded with Stretch. This might explain why when I reboot my Pi, my clients can never log into the password protected broker. When I stop (sudo service mosquitto stop) and then start (mosquitto -d) they all can then connect..

I just went through the process of assigning each client their own unique userid and pw. My assumption is that the mosquitto version that is loaded automatically is not looking for my password file, but then when I manually restart the broker, it loads my password file and all the clients connect.

The location of my password and mosquitto config folder/files is /etc/mosquitto. My question is where is the location of the mosquitto version that the OS is auto starting? Where do I need to go to get this version to load my password file?

Источник

Mosquito error address already in use

‘mosquitto’ is a daemon / service program. After installation (and after rebooting the Pi) it is started automatically.
You’re trying to run it manually after it’s already started. There’s no need for that.

What are you trying to achieve?

Re: mosquitto port 1883 already in use

When you get these port in use problems use lsof (sudo apt-get install lsof) to find the task that’s opened the port.

sudo lsof -i TCP:1883
and you should get something like:

$ sudo lsof -i TCP:1883
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mosquitto 626 mosquitto 3u IPv4 9006 0t0 TCP *:1883 (LISTEN)
mosquitto 626 mosquitto 5u IPv6 9007 0t0 TCP *:1883 (LISTEN)
mosquitto 626 mosquitto 6u IPv4 13534 0t0 TCP pi.example.co.uk:37700->tardis.example.co.uk:1883 (ESTABLISHED)
pi@pi:

So I can instantly tell that pid 626 is the task I’m interested in.

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Re: mosquitto port 1883 already in use

Thanks for the help.
I installed lsof and ran sudo lsof -i TCP:1883
This gave me the response
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mosquitto 2110 mosquitto 3u IPv4 2906 0t0 TCP *:1883 (LISTEN)
Indicating the demon is running as expected but also confirms that no other service is using the port.

I was following some instructions on getting the MQTT to publish some test data, this wasn’t working. I didn’t know how to tell if MQTT is running and was getting the error that the port was in use — lsof tells me it is running so I have a different issue that needs investigating.

Re: mosquitto port 1883 already in use

Open a new window and run
mosquitto_sub -v -t ‘#’

That will subscribe to ANY topic you publish and report the topic name and the payload.

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Источник

Mosquito error address already in use

Mosquitto was running happily on a RPi3B but then traffic suddenly stopped. Not being particularly adept with these technoclogies I attempted to resolve the issue by uninstalling Mosquitto and then reinstalling it.

While the install seemed to go OK the problem was still there. The mqtt broker was no longer apparently operative.

As an example of the log results, after a fresh restart of the Pi he most log shows the following:

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.

Re: Mosquito Error:Address already in use

Two days ago I decided to update my raspberry PI 3 running debian Jessie. After this update I noticed that a new version of mosquitto was installed, version 1.5 and my web client was not receiving any messages anymore. My client is A simple HTML page using paho javascript client that connects to a server using WebSockets. It all run flawless for half a year now but after the update it stopt working thru websockets. When I connect with a different client to port 1883 I see all my messages and I am able to publlise.

Wat I tried so far is:
— comment out the 1883 in the configuration file and rebooted the mosquitto service
— set allow_anonymous to true
— running a netstat command where I see two listener foor mosquitto port 1883 and 9001

pulling my hear out here for two days now, anybody here with the same problem and solved this?

Re: Mosquito Error:Address already in use

@rorie I also noticed my Mosquitto wasupdated to 1.5 in the last couple of days. I don’t seems to have issues with the websocket. Have you tried enabling all log types, and looking at the mosquittto.log to see if the connection and subscriptions are being accepted from the web client?

Something else I found, if you connect to your website with https, then you need to use secure websockets otherwise browsers complain. I’ll assume this isn’t the case if it was working before 1.5 though.

@dweston in the log from mosquitto looks like its trying to start 2 listeners on the port 1883

Re: Mosquito Error:Address already in use

@MrWhite_2018 Thanks for your reply, which version of Debian are you using, stretch or Jesie? In noticed that sending of a message from the webclient to my broker is working, slower dan normally but ik works.

I am using Jessie at the moment, tonight i will make a backup en try to install stretch to see if this solved the problem.

Re: Mosquito Error:Address already in use

@rorie I have Stretch now. When I first installed mosquitto it installed 1.4.10 which worked fine. along the update path for other items I noticed mosquitto updated to 1.5 but still worked fine.

I had issues with 1.5 with Jessie from the webclient. My connections wouldn’t work at all. The logs showed that something was constantly being sent by the broker, but no idea what. I resolved it by upgrading to Stretch.

Re: Mosquito Error:Address already in use

Re: Mosquito Error:Address already in use

It appears that I too am running 2 sessions of Mosquitto Broker (ver 1.5.5) on my RPi3 loaded with Stretch. This might explain why when I reboot my Pi, my clients can never log into the password protected broker. When I stop (sudo service mosquitto stop) and then start (mosquitto -d) they all can then connect..

I just went through the process of assigning each client their own unique userid and pw. My assumption is that the mosquitto version that is loaded automatically is not looking for my password file, but then when I manually restart the broker, it loads my password file and all the clients connect.

The location of my password and mosquitto config folder/files is /etc/mosquitto. My question is where is the location of the mosquitto version that the OS is auto starting? Where do I need to go to get this version to load my password file?

Источник

Error: Address already in use #2142

Just updated to 2.0.9 though DietPi sys and now have an error and can no longer connect

1616235035: mosquitto version 2.0.9 starting
1616235035: Using default config.
1616235035: Starting in local only mode. Connections will only be possible from clients running on this machine.
1616235035: Create a configuration file which defines a listener to allow remote access.
1616235035: Opening ipv4 listen socket on port 1883.
1616235035: Error: Address already in use
1616235035: Opening ipv6 listen socket on port 1883.
1616235035: Error: Address already in use

The text was updated successfully, but these errors were encountered:

It looks as though something else is already listening on port 1883. Can you confirm whether that is the case?

Note also the line Starting in local only mode. Connections will only be possible from clients running on this machine. — see https://mosquitto.org/documentation/authentication-methods/

Thanks, it was running fine before the update

this is my grep LISTEN

tcp LISTEN 0 100 127.0.0.1:26002 : users:((«nxnode.bin»,pid=1281,fd=7))
tcp LISTEN 0 128 :22 : users:((«dropbear»,pid=624,fd=3))
tcp LISTEN 0 128 :1880 : users:((«node-red»,pid=5345,fd=21))
tcp LISTEN 0 128 127.0.0.1:8088 : users:((«influxd»,pid=5354,fd=3))
tcp LISTEN 0 128 127.0.0.1:7002 : users:((«nxnode.bin»,pid=1281,fd=19))
tcp LISTEN 0 100 127.0.0.1:1883 : users:((«mosquitto»,pid=5337,fd=5))
tcp LISTEN 0 50 :445 : users:((«smbd»,pid=5313,fd=32))
tcp LISTEN 0 100 :4000 : users:((«nxd»,pid=807,fd=3))
tcp LISTEN 0 100 127.0.0.1:21024 : users:((«nxserver.bin»,pid=481,fd=8))
tcp LISTEN 0 100 127.0.0.1:12002 : users:((«nxnode.bin»,pid=1281,fd=16))
tcp LISTEN 0 100 127.0.0.1:25002 : users:((«nxclient.bin»,pid=1318,fd=7))
tcp LISTEN 0 50 :139 : users:((«smbd»,pid=5313,fd=33))
tcp LISTEN 0 32 . 21 .
users:((«proftpd»,pid=5292,fd=0))
tcp LISTEN 0 128 . 8086 .
users:((«influxd»,pid=5354,fd=306))
tcp LISTEN 0 128 . 22 .
users:((«dropbear»,pid=624,fd=4))
tcp LISTEN 0 128 . 3001 .
users:((«grafana-server»,pid=5362,fd=12))
tcp LISTEN 0 128 ::1:7002 .
users:((«nxnode.bin»,pid=1281,fd=17))
tcp LISTEN 0 100 ::1:1883 . * users:((«mosquitto»,pid=5337,fd=6))
tcp LISTEN 0 50 . 445 . * users:((«smbd»,pid=5313,fd=30))
tcp LISTEN 0 100 . 4000 . * users:((«nxd»,pid=807,fd=4))
tcp LISTEN 0 50 . 139 . * users

tcp LISTEN 0 100 127.0.0.1:1883 : users:((«mosquitto»,pid=5337,fd=5)) — it looks like Mosquitto is already running.

It sounds like you might be trying to start Mosquitto twice, the first time is a leftover from earlier versions that need deletion. The words below are from a post in another thread.

There was a root CRON job that runs launcher.sh which contained sudo mosquitto -d

How did I find it. Well once I found CRON has a @reboot option I looked further and found CRON is by user including root. So I winged it and tried sudo crontab -l hoping the use of sudo finds root cronjobs instead of pi user jobs and there as a another job.

Источник

Error: Address already in use after fresh installation on Debian 9 «Stretch» (most current version, updated with apt-get upgrade) #1768

Does somebody know what that is?

Does mosquitto -v try to start a new process on the same port 1883 that is already in use due to the mosquitto background service. ( service mosquitto status shows me that is runs which is OK, it must run as a service in our case!)

Thank you for your feedbacks.

With best regards,
Jan

The text was updated successfully, but these errors were encountered:

«You will need to install the mosquitto-clients package if you haven’t done so already.»

So same message as before. -(

Oh, th -v does start mosquitto in a «verbose» mode.

I was thinking it just verifies and print out the service config / mode.

So problem solved and ready to close.

To the project maintainers: If i was wrong, so just re-open it to find an adequate solution.

Just as a comment — the version in Stretch is way, way out of date (nearly 4 years old). I’d suggest you use the repository at repo.mosquitto.org instead.

OK thank you for your informations!

Stretch is (too) old in general — i know. But currently, we need it only for development, testing and prototyping purposes.

But:, So i saw, the mosquitto version on buster does also not support MQTT protocol version 5.x.

From which version does mosquitto support the MQTT 5.x version? Maybe you know that?

(The v3.x vs. v5.x thing is (currently) just a theorecial thing for us — we use it with tasmota and their MQTT client functionality is v3.x. only)

Now i added that to sources.list

  • the updates the required GPG key. After that, apt-gte update was working with the new repo.mosquitto.org-entry.

But: «apt-get upgrade» does not seem to work. I was expecting that this command would update the old mosquitto package from debian.org Strech APT repo.

Maybe apt-get upgrade is only working if the packages come from the same server?

So: Do i need to uninstall the version from Debian Stretch APT-repo first, then install it again with «apt-get install . «

And: Are there NO confilcts between the versions from

Источник

Recommended Posts

Александр Разживин

Newbie

    • Share

Добрый день.

Тема эта не новая, в сети информация есть, но иногда устаревшая и весьма разрозненная. Поэтому по окончании установки на свой кинетик решил написать свою статью, где постарался описать процесс максимально подробно.

Статья получилась достаточно объемная, здесь переписывать весь этот труд лень, да и правки вношу пока что.

Если кому-то будет полезно: https://kotyara12.ru/pubs/iot/keenetic-mqtt/

Link to comment
Share on other sites

  • 2 weeks later…

Andriy Shushlebin

Newbie

    • Share

Прошу помощи, уже 3ий день бьюсь

Делаю все по инструкции (этой и аналогичным), установил, пользователя добавил

далее запускаю  mosquitto -v

и получаю

1621457939: mosquitto version 2.0.10 starting
1621457939: Using default config.
1621457939: Starting in local only mode. Connections will only be possible from clients running on this machine.
1621457939: Create a configuration file which defines a listener to allow remote access.
1621457939: For more details see https://mosquitto.org/documentation/authentication-methods/
1621457939: Opening ipv4 listen socket on port 1883.
1621457939: Opening ipv6 listen socket on port 1883.
1621457939: Error: Cannot assign requested address
1621457939: mosquitto version 2.0.10 running

Что я делаю не так?

  • Quote

Link to comment
Share on other sites

  • 3 months later…

umc

Newbie

    • Share

такая же фигня … кто в теме помогите 

1631087443: mosquitto version 2.0.11 starting
1631087443: Using default config.
1631087443: Starting in local only mode. Connections will only be possible from clients running on this machine.
1631087443: Create a configuration file which defines a listener to allow remote access.
1631087443: For more details see https://mosquitto.org/documentation/authentication-methods/
1631087443: Opening ipv4 listen socket on port 1883.
1631087443: Error: Address already in use
1631087443: Opening ipv6 listen socket on port 1883.
1631087443: Error: Address already in use
 

На OpenWrt установил пакет mosquitto-nossl и всё работает само и сразу , а тут как-то не работает

  • Quote

Link to comment
Share on other sites

ajs

Honored Flooder

    • Share

В 20.05.2021 в 00:01, Andriy Shushlebin сказал:

Что я делаю не так?

Он у вас стартанул, но в локальном режиме, о чем и написал… Ну и на IPV6 не смог забиндить себя …

37 минут назад, umc сказал:

такая же фигня … кто в теме помогите 

Пишет что адрес/порт занят … как 4 так и 6 …

  • Quote

Link to comment
Share on other sites

umc

Newbie

    • Share

То что порт занят я смог перевести … Почему и чем ?… Сбросил роутер к заводским настройкам , форматнул флешку и заново установил Entware . Установил только mosquitto . Результат тот же … порт занят.

Что предпринять?

  • Quote

Link to comment
Share on other sites

  • 1 month later…

umc

Newbie

    • Share

В 20.05.2021 в 00:01, Andriy Shushlebin сказал:

Прошу помощи, уже 3ий день бьюсь

Делаю все по инструкции (этой и аналогичным), установил, пользователя добавил

далее запускаю  mosquitto -v

и получаю

1621457939: mosquitto version 2.0.10 starting
1621457939: Using default config.
1621457939: Starting in local only mode. Connections will only be possible from clients running on this machine.
1621457939: Create a configuration file which defines a listener to allow remote access.
1621457939: For more details see https://mosquitto.org/documentation/authentication-methods/
1621457939: Opening ipv4 listen socket on port 1883.
1621457939: Opening ipv6 listen socket on port 1883.
1621457939: Error: Cannot assign requested address
1621457939: mosquitto version 2.0.10 running

Что я делаю не так?

Итак … решение найдено (сам столкнулся с такой проблемой)

Дело в том, что из-за изменений в версии старше 2.0.x анонимность по умолчанию запрещена.

В файл mosquito.conf добавьте следующие строки:

listener 1883

allow_anonymous true

Если установить версию ниже 2.0.x, то для начала нужно удалить ранее установленную opkg remove mosquitto-nossl . Также потребуется удалить файл mosquitto.conf 

Далее устанавливаем opkg install http://bin.entware.net/mipselsf-k3.4/archive/mosquitto-nossl_1.5-3_mipsel-3.4.ipk 

( версию можно выбрать здесь http://bin.entware.net/mipselsf-k3.4/archive/ )

Далее по инструкции http://www.windwheel.ru/?module=articles&c=news&b=1&a=40

  • Quote

Link to comment
Share on other sites

  • 3 weeks later…

Илдар Каримов

Newbie

    • Share

На шаге «Перезапускаем роутер. Снова подключаемся к роутеру по SSH и пробуем запустить mosquitto командой mosquitto -c /opt/etc/mosquitto/mosquitto.conf -d, после чего проверяем успешность запуска с помощью команды ps
при вводе «
mosquitto -c /opt/etc/mosquitto/mosquitto.conf -d»

Выдает «1636290088: Error: Unable to open config file /opt/etc/mosquitto.conf.»

Что делать?

  • Quote

Link to comment
Share on other sites

Join the conversation

You can post now and register later.

If you have an account, sign in now to post with your account.

Note: Your post will require moderator approval before it will be visible.

Модератор: immortal

Yashalta

Сообщения: 313
Зарегистрирован: Вс май 20, 2018 9:27 am
Благодарил (а):
160 раз
Поблагодарили:
28 раз

Не работает MQTT. [РЕШЕНО]

Подскажите, не знаю куда «копать»!
Установлен «MD» на «Ubuntu 20.04 LTS» на ноут.
Все работает но, вот с «MQTT» проблема!
Есть так же «Raspberry PI 3b» на ней все работает включая «MQTT»! Это я к тому, что я перенес backup c Raspberry на ноут и развернул его там…

Может это важно?!
«MD» который на «Ubuntu 20.04 LTS» имеет путь до «web serverа» /var/www $
а
«MD» который на «Raspberry PI 3b» имеет путь до «web serverа « /var/www/html $

Вложения
111png.png
111png.png (60.58 КБ) 1290 просмотров

Последний раз редактировалось Yashalta Сб июл 04, 2020 11:10 am, всего редактировалось 1 раз.

Yashalta

Сообщения: 313
Зарегистрирован: Вс май 20, 2018 9:27 am
Благодарил (а):
160 раз
Поблагодарили:
28 раз

Re: Не работает MQTT.

Сообщение

Yashalta » Сб июл 04, 2020 11:08 am

Отвечаю для таких как я!
после того как ручками установлен «MD» на какую либо «OS» в моем случае это «Ubuntu 20.04 LTS»
Для «MQTT» не достаточно просто развернуть «BackUp» от «MajorDomo», нужно также и установить «MQTT» в саму «Ubuntu 20.04 LTS»!

Код: Выделить всё

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
sudo apt clean

Так же нужно изменить значение persistence в файле /etc/mosquitto/mosquitto.conf на false!

меняем значение
persistence true
на
persistence false
Так сделано в образе для Raspberry от Сергея…
Для чего это нужно прогуглите если интересно.

Перезагружаем «OS» и готово!

Для проверки

Код: Выделить всё

user@majordomo:~$ sudo /etc/init.d/mosquitto status

● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
     Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-07-04 07:43:52 UTC; 44min ago
       Docs: man:mosquitto.conf(5)
             man:mosquitto(8)
   Main PID: 845 (mosquitto)
      Tasks: 1 (limit: 1979)
     Memory: 2.1M
     CGroup: /system.slice/mosquitto.service
             └─845 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jul 04 07:43:50 majordomo systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 B…r...
Jul 04 07:43:52 majordomo systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.
Hint: Some lines were ellipsized, use -l to show in full.

Код: Выделить всё

sudo apt install net-tools

user@majordomo:~$ netstat –at
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
... 
tcp        0      0 localhost:1883          localhost:36500         ESTABLISHED
tcp        0      0 localhost:36500         localhost:1883          ESTABLISHED
...

Код: Выделить всё

user@majordomo:~$ mosquitto -v
1593848740: mosquitto version 1.6.10 starting
1593848740: Using default config.
1593848740: Opening ipv4 listen socket on port 1883.
1593848740: Error: Address already in use
user@majordomo:~$

Moderators: grovkillen, Stuntteam, TD-er

espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

cannot connect to MQTT broker.

#1

Post

by espfrm883 » 28 Sep 2015, 00:36

Hello all,

I need some fresh eyes to help troubleshoot my Problem. The ESP indicates that it cannot connect to the broker. I’ve tested Mosquitto with the following commands as well as a simple andriod app (MyMQTT).

Terminal 1
mosquitto_sub -v -t ‘test/topic’

Terminal 2
mosquitto_pub -t ‘test/topic’ -m ‘helloWorld’

This was a successful test. However don’t know how to make sure that OpenHAB is receiving or pushing the commands. What topic in the MyMQTT should I put in to the phone to test openHAB?

I’m open to any other suggestions as well.

thank you to the esp8266nu team for a great project. :D

################################# Generic ESP8266 ######################################
System Info
Uptime: 20 minutes
IP: 192.168.2.189
GW: 192.168.2.1
Build: 20
Unit: 16
STA MAC: 18:fe:34:fe:60:5d
AP MAC: 1a:fe:34:fe:60:5d
ESP Chip ID: 16670813
ESP Flash Size: 524288
Free Mem: 25448

Main Settings
Name: demo
Admin Password: pass
SSID: MYSSID
WPA Key: MYPASSWD
WPA AP Mode Key: configesp
Unit nr: 16
Protocol: OpenHAB MQTT
Controller IP: 192.168.2.125
Controller Port: 1883
Sensor Delay: 60
Message Delay (ms): 1000
Sleep Mode: 0
Optional Settings 0.0.0.0
Fixed IP Octet: 0.0.0.0
ESP IP: 0.0.0.0
ESP GW: 0.0.0.0
ESP Subnet: 0.0.0.0
Syslog IP: 0.0.0.0
Syslog Level: 0
UDP port: 0
Serial log Level: 3
Web log Level: 3
Baud Rate: 115200

################################# OpenHAB MQTT Transport ######################################
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with a id you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mqtt:mymosquitto.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
mqtt:mymosquitto.clientId=openHAB

################################# OpenHAB Items ######################################
Switch MQTTLED (test) {mqtt=»>[mymosquitto:/demo/gpio/2:command:ON:1],>[mymosquitto:/demo/gpio/2:command:OFF:0]»}


espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

Re: cannot connect to MQTT broker.

#2

Post

by espfrm883 » 29 Sep 2015, 04:19

I have confirmed the issue is with ESPEasy after plugging in my old Mosquitto gateway and RFM69HW.

— How can I turn on debug while watching the serial monitor?
— I’ll build out my ESP826612 this weekend to see if the problem is limited to the generic ESP.

side note: I’ve found out that my OpenHab on Raspberry Pi loads and runs better by limiting addons to the one actually used.


espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

Re: cannot connect to MQTT broker.

#3

Post

by espfrm883 » 30 Sep 2015, 03:49

Ok. Here’s the log. I’ve attempted this with an ESP826612 as well as a generic.

HTTP : Tools request :
HTTP : Webrequest : reboot
: Rebooting…

ets Jan 8 2013,rst cause:4, boot mode:(3,3)

wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
ªU
INIT : Booting Build nr:20
scandone
del if0
usl
sul 0 0
mode : softAP(1a:fe:34:a6:76:90)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
bcn 0
del if1
usl
sul 0 0
mode : sta(18:fe:34:a6:76:90)
add if0
WIFI : Connecting…
f 0, .
.
.
.
scandone
state: 0 -> 2 (b0)
.
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 8
pm open phy_2,type:2 0 0
cnt

connected with MYNET, channel 2
dhcp client start…
.
.
.
ip:192.168.2.198,mask:255.255.255.0,gw:192.168.2.1
.
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
INIT : Boot OK
Boot
0
normal boot


Martinus

Re: cannot connect to MQTT broker.

#4

Post

by Martinus » 30 Sep 2015, 15:08

When the ESP got it’s IP, can you ping the device on that IP?
Do you have some generic webserver running so you could try if the ESP connects through HTTP to something?
Use debug level 3 and it should show something like this:

Code: Select all

HTTP : connecting to 192.168.0.40
HTTP : closing connection

(I have a plain webserver running on 192.168.0.40 and at least it will connect to it even though this is not Domoticz or some other HA solution)

Then we know at least that communication is working and the issue must be something within MQTT connection.


espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

Re: cannot connect to MQTT broker.

#5

Post

by espfrm883 » 30 Sep 2015, 22:54

Thank you for the reply.. I still am having the same problem.

What do you think of the issue being a clentname problem?

My broker is configured to all the defaults which allow anonymous and I don’t think that I have a client name configured on any of the other clients (Andriod and Arduino).

The ESP has an IP address. Here’s the System Info.

System Info
Uptime: 0 minutes
IP: 192.168.2.198
GW: 192.168.2.1
Build: 18
Unit: 16
STA MAC: 18:fe:34:a6:76:90
AP MAC: 1a:fe:34:a6:76:90
ESP Chip ID: 10909328
ESP Flash Size: 4194304
Free Mem: 26232

I can ping the ESP from the MQTT server

PING 192.168.2.198 (192.168.2.198) 56(84) bytes of data.
64 bytes from 192.168.2.198: icmp_req=1 ttl=255 time=26.2 ms
64 bytes from 192.168.2.198: icmp_req=2 ttl=255 time=49.2 ms
64 bytes from 192.168.2.198: icmp_req=3 ttl=255 time=2.01 ms

I still have a problem connecting to the broker. Even though other devices can including my phone and an Arduino Gateway.
I’ve updated the logging to level 3 and this is all I get.

INIT : Booting Build nr:18
INIT : I2C
WIFI : Connecting…
.
.
.
.
.
.
.
.
.
MQTT : Failed to connected to broker
MQTT : Failed to connected to broker
INIT : Boot OK
Boot
WD : Uptime 0 ConnectFailures 0 FreeMem 26232


espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

Re: cannot connect to MQTT broker.

#6

Post

by espfrm883 » 01 Oct 2015, 05:08

Solved BABY! :D

The issue is with the default Mosquitto repository incompatible with ESP. Credit goes to this post
http://mosquitto.org/2013/01/mosquitto- … epository/

I uninstalled the existing broker.

Code: Select all

sudo /etc/init.d/mosquitto stop 
sudo apt-get --purge remove mosquitto mosquitto-clients python-mosquitto

To use the new repository you should first import the repository package signing key:

Code: Select all

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key

Then make the repository available to apt:

Then one of the following, depending on which version of debian you are using: (I used wheezy)

Code: Select all

sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list

Then update apt information:

And discover what mosquitto packages are available:

Or just install:

And the sweet result:

INIT : Booting Build nr:18
INIT : I2C
WIFI : Connecting…
.
.
.
.
.
.
.
MQTT : Connected to broker
INIT : Boot OK
Boot
gpio,2,0
gpio,2,1
gpio,2,0


MarkIngle

Normal user
Posts: 47
Joined: 10 Feb 2016, 05:06

Re: cannot connect to MQTT broker.

#7

Post

by MarkIngle » 13 Feb 2016, 06:21

Thanks for posting this! Now if I can just figure it out for Windows 7!


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#8

Post

by Gorgo » 09 Mar 2016, 16:22

That’s a bit weird for me. I’ve reinstalled mosquitto following the sample (I’ve picked Jessie), and after listed the packages available I chose just install.

After it’s been done checked its status:

Code: Select all

pi@arcpi:~ $ sudo /etc/init.d/mosquitto status
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto)
   Active: active (running) since Wed 2016-03-09 16:10:45 CET; 2min 59s ago
  Process: 392 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mosquitto.service
           └─402 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Mar 09 16:10:45 arcpi mosquitto[392]: Starting network daemon:: mosquitto.
Mar 09 16:10:45 arcpi systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.

It says 1.4.8 v3.1

Should I give a try to Wheezy version?


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#9

Post

by Gorgo » 09 Mar 2016, 16:49

Tried, but I see no difference. ESP is still unable to connect broker.
I find this interesting:

Code: Select all

● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto)
   Active: active (running) since Wed 2016-03-09 16:40:37 CET; 1min 57s ago
  Process: 395 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mosquitto.service
           └─413 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Mar 09 16:40:37 arcpi mosquitto[395]: Starting network daemon:: mosquitto.
Mar 09 16:40:37 arcpi systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
pi@arcpi:~ $ mosquitto
1457538339: mosquitto version 1.4.8 (build date Sun, 14 Feb 2016 15:06:55 +0000) starting
1457538339: Using default config.
1457538339: Opening ipv4 listen socket on port 1883.
1457538339: Error: Address already in use

Still 3.1 and that error message in the last line where this should be: «Opening ipv6 listen socket on port 1883.»
Possibly that is wrong here but got no idea how to figure it out.
Any help appreciated.


espfrm883

Normal user
Posts: 30
Joined: 28 Sep 2015, 00:07

Re: cannot connect to MQTT broker.

#10

Post

by espfrm883 » 09 Mar 2016, 16:57

Looks like your other mosquitto broker may be running.


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#11

Post

by Gorgo » 09 Mar 2016, 17:13

As far as I know there is no other broker.


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#12

Post

by Gorgo » 09 Mar 2016, 18:01

OK, after Mosquitto already running typing «mosquitto» to the terminal window tries to start it again, maybe that’s the reason.
But still unable to connect to broker.

I read somewhere that there is a syntax issue with «/%sysname%…» -that maybe the «/» is not needed at the beginning… I just can’t find it anymore.


tozett

Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: cannot connect to MQTT broker.

#13

Post

by tozett » 10 Mar 2016, 07:34

check running tasks with «ps» or «ps -xa» to see how many mosquittos are running…
than check connection with mosquitto_sub client…

show what the findings are..


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#14

Post

by Gorgo » 10 Mar 2016, 13:06

Thank you.

Erased then reinstalled EspEasy, after reboot I get this on serial:

INIT : Booting Build nr:78
WIFI : Connecting… 1
WIFI : Connected!
INIT : I2C
MQTT : Failed to connected to broker
MQTT : Connected to broker
Subscribed to: unit1/#
INIT : Boot OK
INIT : Cold Boot
WD : Uptime 0 ConnectFailures 0 FreeMem 26176
WD : Uptime 1 ConnectFailures 0 FreeMem 26144
WD : Uptime 1 ConnectFailures 0 FreeMem 25952
WD : Uptime 2 ConnectFailures 0 FreeMem 25824
WD : Uptime 2 ConnectFailures 0 FreeMem 25240
WD : Uptime 3 ConnectFailures 0 FreeMem 25760
WD : Uptime 3 ConnectFailures 0 FreeMem 25760
WD : Uptime 4 ConnectFailures 0 FreeMem 25712
WD : Uptime 4 ConnectFailures 0 FreeMem 25712
WD : Uptime 5 ConnectFailures 0 FreeMem 25648
WD : Uptime 5 ConnectFailures 0 FreeMem 25632
WD : Uptime 6 ConnectFailures 0 FreeMem 25632

Pi through terminal:

pi@arcpi:~ $ ps -xa
PID TTY STAT TIME COMMAND
1 ? Ss 0:08 /sbin/init
2 ? S 0:00 [kthreadd]
3 ? S 0:04 [ksoftirqd/0]
5 ? S< 0:00 [kworker/0:0H]
7 ? S 0:20 [rcu_sched]
8 ? S 0:00 [rcu_bh]
9 ? S 0:00 [migration/0]
10 ? S 0:00 [migration/1]
11 ? S 0:00 [ksoftirqd/1]
13 ? S< 0:00 [kworker/1:0H]
14 ? S 0:00 [migration/2]
15 ? S 0:00 [ksoftirqd/2]
17 ? S< 0:00 [kworker/2:0H]
18 ? S 0:00 [migration/3]
19 ? S 0:00 [ksoftirqd/3]
21 ? S< 0:00 [kworker/3:0H]
22 ? S< 0:00 [khelper]
23 ? S 0:00 [kdevtmpfs]
24 ? S< 0:00 [netns]
25 ? S< 0:00 [perf]
26 ? S 0:00 [khungtaskd]
27 ? S< 0:00 [writeback]
28 ? S< 0:00 [crypto]
29 ? S< 0:00 [bioset]
30 ? S< 0:00 [kblockd]
32 ? S< 0:00 [rpciod]
34 ? S 0:00 [kswapd0]
35 ? S 0:00 [fsnotify_mark]
36 ? S< 0:00 [nfsiod]
42 ? S< 0:00 [kthrotld]
44 ? S< 0:00 [VCHIQ-0]
45 ? S< 0:00 [VCHIQr-0]
46 ? S< 0:00 [VCHIQs-0]
47 ? S< 0:00 [iscsi_eh]
48 ? S< 0:00 [dwc_otg]
49 ? S< 0:00 [DWC Notificatio]
51 ? S 0:28 [mmcqd/0]
52 ? S 0:00 [VCHIQka-0]
53 ? S< 0:00 [SMIO]
54 ? S< 0:00 [deferwq]
55 ? S 0:10 [jbd2/mmcblk0p2-]
56 ? S< 0:00 [ext4-rsv-conver]
59 ? S< 0:00 [ipv6_addrconf]
107 ? Ss 0:02 /lib/systemd/systemd-journald
108 ? Ss 0:00 /lib/systemd/systemd-udevd
187 ? S 0:00 [spi0]
366 ? S 0:52 [RTW_CMD_THREAD]
381 ? Ss 0:00 /usr/sbin/cron -f
384 ? Ss 0:00 /lib/systemd/systemd-logind
395 ? Ss 0:00 avahi-daemon: running [arcpi.local]
397 ? Ss 0:00 /usr/bin/dbus-daemon —system —address=systemd: —nofork —nopidfile
413 ? S 0:42 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
418 ? Ss 0:00 /usr/sbin/thd —daemon —triggers /etc/triggerhappy/triggers.d/ —soc
422 ? S< 0:00 [cfg80211]
426 ? Ss 0:00 /sbin/dhcpcd -q -b
433 ? S 0:00 avahi-daemon: chroot helper
437 ? Ss 0:05 /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlan0.pid -i wlan0
477 ? Ssl 0:00 /usr/sbin/rsyslogd -n
483 ? S< 0:00 [kworker/3:1H]
509 ? Sl 20:58 /usr/bin/java -Djna.boot.library.path=/usr/lib/jni -Dgnu.io.rxtx.Seri
514 ? Ss 0:00 /usr/sbin/sshd -D
527 ? Ssl 0:00 /usr/sbin/lightdm
566 ? Ss 0:10 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:111
614 tty1 Ss 0:00 /bin/login -f
615 ? Ss+ 0:00 /sbin/agetty —keep-baud 115200 38400 9600 ttyAMA0 vt102
635 tty7 Ssl+ 0:34 /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tc
689 ? Sl 0:00 lightdm —session-child 13 16
700 ? Ss 0:00 /lib/systemd/systemd —user
705 ? S 0:00 (sd-pam)
709 ? Ssl 0:00 /usr/bin/lxsession -s LXDE-pi -e LXDE
727 ? S< 0:00 [kworker/1:1H]
728 ? Ss 0:15 /usr/sbin/nmbd -D
746 ? Ss 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch —exit-with-session x-session
749 ? S 0:00 /usr/bin/dbus-launch —exit-with-session x-session-manager
750 ? Ss 0:00 /usr/bin/dbus-daemon —fork —print-pid 5 —print-address 7 —session
760 ? Sl 0:00 /usr/lib/gvfs/gvfsd
766 ? S< 0:00 [kworker/2:1H]
767 ? S< 0:00 [kworker/0:1H]
775 tty1 S+ 0:00 -bash
777 ? Sl 0:00 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
787 ? Ss 0:05 /usr/sbin/smbd -D
832 ? S 0:00 /usr/sbin/smbd -D
843 ? S 0:01 openbox —config-file /home/pi/.config/openbox/lxde-pi-rc.xml
846 ? Sl 0:00 lxpolkit
848 ? Sl 2:44 lxpanel —profile LXDE-pi
849 ? Sl 0:00 pcmanfm —desktop —profile LXDE-pi
858 ? Ss 0:00 /usr/bin/ssh-agent -s
860 ? Ssl 0:00 /usr/lib/policykit-1/polkitd —no-debug
869 ? Sl 0:00 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
871 ? Ssl 0:00 /usr/lib/udisks2/udisksd —no-debug
883 ? Sl 0:00 /usr/lib/gvfs/gvfs-goa-volume-monitor
887 ? Sl 0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
892 ? Sl 0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
896 ? Sl 0:00 /usr/lib/gvfs/gvfs-mtp-volume-monitor
911 ? Sl 0:00 /usr/lib/gvfs/gvfsd-trash —spawner :1.1 /org/gtk/gvfs/exec_spaw/0
912 ? Ssl 0:00 /usr/lib/menu-cache/menu-cached /tmp/.menu-cached-:0-pi
10798 ? S 0:00 [kworker/u8:1]
16470 ? S 0:01 [kworker/u8:0]
17887 ? S 0:01 [kworker/1:2]
18225 ? S 0:00 [kworker/2:0]
18882 ? S 0:00 [kworker/3:2]
18908 ? S 0:00 [kworker/2:1]
18926 ? S 0:00 [kworker/1:1]
18938 ? S 0:00 [kworker/0:2]
18967 ? S 0:00 [kworker/3:1]
19014 ? S 0:00 [kworker/0:1]
19078 ? S 0:00 [kworker/2:2]
19094 ? Ss 0:00 sshd: pi [priv]
19096 ? S 0:00 [kworker/0:0]
19103 ? Ss 0:00 sshd: pi [priv]
19106 ? S 0:00 sshd: pi@pts/0
19118 ? S 0:00 sshd: pi@notty
19121 ? Ss 0:00 /usr/lib/openssh/sftp-server
19122 pts/0 Ss 0:00 -bash
19162 pts/0 R+ 0:00 ps -xa

pi@arcpi:~ $ mosquitto_sub -d -t unit1/#
Client mosqsub/19358-arcpi sending CONNECT
Client mosqsub/19358-arcpi received CONNACK
Client mosqsub/19358-arcpi sending SUBSCRIBE (Mid: 1, Topic: unit1/#, QoS: 0)
Client mosqsub/19358-arcpi received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/19358-arcpi sending PINGREQ
Client mosqsub/19358-arcpi received PINGRESP
Client mosqsub/19358-arcpi sending PINGREQ
Client mosqsub/19358-arcpi received PINGRESP
Client mosqsub/19358-arcpi sending PINGREQ
Client mosqsub/19358-arcpi received PINGRESP
Client mosqsub/19358-arcpi sending PINGREQ
Client mosqsub/19358-arcpi received PINGRESP

It seems almost OK now, isn’t it?
Actually I can’t define the lines like «WD : Uptime 0 ConnectFailures 0 FreeMem 26176».


Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#15

Post

by Gorgo » 10 Mar 2016, 14:20

Perfect.
Now I can turn GPIOs on and off through the broker.
How should the responses (state change confirmation) appear from the ESP on the broker? Later I want to drive my nodes via OpenHab, so I’ll need to have status reports to keep it sane…

Subscribed to the topic unit1/# -and when I manually publish on it I see this:

Code: Select all

Client mosqsub/19358-arcpi received PUBLISH (d0, q0, r0, m0, 'unit1/gpio/2', ... (1 bytes))
0
Client mosqsub/19358-arcpi received PUBLISH (d0, q0, r0, m0, 'unit1/gpio/2', ... (1 bytes))
0
Client mosqsub/19358-arcpi received PUBLISH (d0, q0, r0, m0, 'unit1/gpio/2', ... (1 bytes))
1
Client mosqsub/19358-arcpi sending PINGREQ
Client mosqsub/19358-arcpi received PINGRESP

but nothing from the ESP.



Gorgo

Normal user
Posts: 20
Joined: 14 Feb 2016, 11:40

Re: cannot connect to MQTT broker.

#17

Post

by Gorgo » 10 Mar 2016, 14:59

Thank you, already read that.

SUB template:%sysname%/#
PUB template: %sysname%/%tskname%/%valname%

Removed the first «/»

Don’t use a leading forward slash

It is allowed to use a leading forward slash in MQTT, for example /myhome/groundfloor/livingroom. But that introduces a unnecessary topic level with a zero character at the front. That should be avoided, because it doesn’t provide any benefit and often leads to confusion.

http://www.hivemq.com/blog/mqtt-essenti … -practices

My question is to be exact: I should see the ESP’s response on the mosquitto_sub terminal under «unit1/#» topic, right?

Thank you for your time and effort.


jackwan1

Normal user
Posts: 21
Joined: 11 Apr 2017, 05:42

Re: cannot connect to MQTT broker.

#18

Post

by jackwan1 » 12 Apr 2017, 00:11

Hi all,

I am new here and needs all the help.

I am using Ubuntu 16.10 default mosquitto installation on a local host, the MQTT clients can log on to it without any problem.
Flashed sonoff device with R147 ESPeasy
This thread is of great help, so I set in the «advanced» tool section of the ESP easy (removed the first / in each)

subscribe template: %sysname%/
publish template: %sysname%/%tskname%/%valname%

and the subscription topic of : sonoff1/# is working, I am getting system info from subscription.
However the publish part become a problem
I have tried : sonoff1/gpio/12 or sonoff1/gpio/0 or sonoff1/lightswitch/Switch with no success the lightswitch and Switch are the task name and value in the Device configuration.

Before the above, I have the «/» in front of the template and «/» in front of subscribe or publish that does not work either.


jackwan1

Normal user
Posts: 21
Joined: 11 Apr 2017, 05:42

Re: cannot connect to MQTT broker.

#19

Post

by jackwan1 » 12 Apr 2017, 00:24

Ok Ok its all good

it turned out that while subscribe you cannot have a / , publish you need a /
it is weird

So the templates

subscribe : %sysname%/
publish : %sysname%/%tskname%/%valname%

But the clients need

subscribe: sonoff1/#
publish: /sonoff1/gpio/0 or 12

minor difference, but major headache.

In the commercial broker such as cloudmqtt and mqtt-dashboard

the subscribe template must be /%sysname%/
the publish template must be /%sysname%/%tskname%/%valname%

and the clients call must have / in front


jackwan1

Normal user
Posts: 21
Joined: 11 Apr 2017, 05:42

Re: cannot connect to MQTT broker.

#20

Post

by jackwan1 » 12 Apr 2017, 06:35

Ok, now after reboot the conventions seem corrected themselves

So the templates

subscribe : %sysname%/
publish : %sysname%/%tskname%/%valname%

Then the clients need

subscribe: sonoff1/#
publish: sonoff1/gpio/0 or 12

no more / in the publish phase


User avatar

grovkillen

Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: cannot connect to MQTT broker.

#21

Post

by grovkillen » 12 Apr 2017, 06:55

I think many cloud based brokers use a unique identifier for the clients, thus the need to have a leading slash (which isn’t leading really). I.e.

123e4567-e89b-12d3-a456-42665544000/sonoff1/gpio/0


Who is online

Users browsing this forum: No registered users and 0 guests

Понравилась статья? Поделить с друзьями:
  • Mount and blade warband как изменить флаг
  • Mos checksum error defaults loaded
  • Mount and blade warband как изменить сохранение
  • Mortal shell ошибка при запуске
  • Mount and blade warband как изменить размер битвы