OldPCGuy
Posts: 74
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

pi@raspberrypi:~ $ 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: 32376
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: 74
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: 32376
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: 113
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

pi@raspberrypi:~ $ 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: 8987
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: 113
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: 8987
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

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.

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

pi@vistacontroltest:~ $ sudo lsof -i TCP:1883
pi@vistacontroltest:~ $
And:

Code: Select all

pi@vistacontroltest:~ $ netstat | grep 1883
pi@vistacontroltest:~ $

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: 32376
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.

Return to “General programming discussion”

Who is online

Users browsing this forum: No registered users and 1 guest