OldPCGuy
Posts: 81
Joined: Mon Jan 02, 2017 4:53 pm
Location: Detroit Michigan

Mosquito Error:Address already in use

Sat Mar 31, 2018 2:34 pm

When I launch Mosquitto on a PI3 with the intent to run as a Broker I get the following error;

Code: Select all

[email protected]:~ $ mosquitto -v
1522506340: mosquitto version 1.4.10 (build date Mon, 29 May 2017 13:43:29 +0100) starting
1522506340: Using default config.
1522506340: Opening ipv4 listen socket on port 1883.
1522506340: Error: Address already in use
What is the error "address already in use" Do I need to worry about it?

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Mosquito Error:Address already in use

Sat Mar 31, 2018 3:42 pm

You've got two copies running. A stock install sets mosquitto up as a systemd service that will start at boot time.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

OldPCGuy
Posts: 81
Joined: Mon Jan 02, 2017 4:53 pm
Location: Detroit Michigan

Re: Mosquito Error:Address already in use

Sat Mar 31, 2018 7:38 pm

DougieLawson wrote:
Sat Mar 31, 2018 3:42 pm
You've got two copies running. A stock install sets mosquitto up as a systemd service that will start at boot time.
I did not realise that.

Rather than generate a test Sub and Pub is there a command line Ping_Req to check that the Broker is running? I can't find any syntax examples in my searches.

User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Mosquito Error:Address already in use

Sat Mar 31, 2018 9:42 pm

How about: http://www.steves-internet-guide.com/wp ... tt-ping.7z

Needs p7zip and paho-mqtt to extract that and run it.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

droleary
Posts: 150
Joined: Fri Feb 09, 2018 3:45 am
Location: Minneapolis, MN USA
Contact: Website Skype

Re: Mosquito Error:Address already in use

Sun Apr 01, 2018 2:15 am

OldPCGuy wrote:
Sat Mar 31, 2018 7:38 pm
Rather than generate a test Sub and Pub is there a command line Ping_Req to check that the Broker is running?
Same as any system service:

Code: Select all

[email protected]:~ $ 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 Sun 2018-03-18 01:37:56 UTC; 2 weeks 0 days ag
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/mosquitto.service
           └─18287 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Mar 18 01:37:56 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 messag
Mar 18 01:37:56 raspberrypi mosquitto[18281]: Starting network daemon:: mosquitt
Mar 18 01:37:56 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message

Heater
Posts: 9337
Joined: Tue Jul 17, 2012 3:02 pm

Re: Mosquito Error:Address already in use

Sun Apr 01, 2018 7:50 am

Don't you mean:

$ sudo systemctl status mosquitto

?

droleary
Posts: 150
Joined: Fri Feb 09, 2018 3:45 am
Location: Minneapolis, MN USA
Contact: Website Skype

Re: Mosquito Error:Address already in use

Sun Apr 01, 2018 2:10 pm

No I do not. Using systemctl is specific to systemd. While that may be the Debian default now and for the foreseeable future, service is more compatible on a wider variety of Linux installs.

Heater
Posts: 9337
Joined: Tue Jul 17, 2012 3:02 pm

Re: Mosquito Error:Address already in use

Sun Apr 01, 2018 4:17 pm

Good point.

I guess I have been stuck in Debian land for two decades now so I don't think about any other distros.

dweston
Posts: 2
Joined: Wed Nov 09, 2016 10:49 am

Re: Mosquito Error:Address already in use

Fri May 25, 2018 7:38 am

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

[email protected]:~ $ 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

[email protected]:~ $ ps -ef | grep mosquitto
pi        1529  1387  0 06:25 pts/0    00:00:00 grep --color=auto mosquitto
[email protected]:~ $ 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

[email protected]:~ $ 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.

dweston
Posts: 2
Joined: Wed Nov 09, 2016 10:49 am

Re: Mosquito Error:Address already in use

Sat May 26, 2018 9:46 am

There does not appear to be any process using port 1883:

Code: Select all

[email protected]:~ $ sudo lsof -i TCP:1883
[email protected]:~ $
And:

Code: Select all

[email protected]:~ $ netstat | grep 1883
[email protected]:~ $

MichaelEFlip
Posts: 1
Joined: Sat May 26, 2018 10:52 am

Re: Mosquito Error:Address already in use

Sat May 26, 2018 10:55 am

I have the same problem since the latest version (1.5.0).


User avatar
DougieLawson
Posts: 33003
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Mosquito Error:Address already in use

Sat May 26, 2018 2:37 pm

Remove

Code: Select all

listener 1883
from your config files. It's a feechur of 1.5 that crept in when they built that buggy version.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

rorie
Posts: 3
Joined: Thu May 31, 2018 7:06 am

Re: Mosquito Error:Address already in use

Thu May 31, 2018 7:10 am

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?

MrWhite_2018
Posts: 6
Joined: Thu May 31, 2018 11:23 am

Re: Mosquito Error:Address already in use

Thu May 31, 2018 4:36 pm

@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

Code: Select all

-->1527229407: Opening ipv4 listen socket on port 1883.<--
1527229407: Opening ipv6 listen socket on port 1883.
--> 1527229407: Opening ipv4 listen socket on port 1883. <--
I've had that error before, but ususally after I try to restart the service. I usually need to wait a few seconds for the ports to close before trying to start the service again.

rorie
Posts: 3
Joined: Thu May 31, 2018 7:06 am

Re: Mosquito Error:Address already in use

Mon Jun 04, 2018 9:10 am

@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.

MrWhite_2018
Posts: 6
Joined: Thu May 31, 2018 11:23 am

Re: Mosquito Error:Address already in use

Mon Jun 04, 2018 11:43 am

@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.

rorie
Posts: 3
Joined: Thu May 31, 2018 7:06 am

Re: Mosquito Error:Address already in use

Tue Jun 05, 2018 6:33 am

After a new installation of Debian Stretch on my Rasberry Pi 3 my mosquitto broker is working again with websockets. It seems that mosquitto 1.5 with websockets is not working in Debian Jessie.

Return to “General programming discussion”

Who is online

Users browsing this forum: No registered users and 7 guests