balenaOS is listening to MQTT port 1883

I have stopped all service and executed command netstat -lt in my host OS terminal window and it outputted the following.

root@ba7c427:~# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
tcp        0      0 127.0.0.2:domain        0.0.0.0:*               LISTEN      
tcp        0      0 10.114.102.1:domain     0.0.0.0:*               LISTEN      
tcp        0      0 :::1883                 :::*                    LISTEN      
tcp        0      0 :::48484                :::*                    LISTEN      
tcp        0      0 :::22222                :::*                    LISTEN      
root@ba7c427:~# 

So it appears to be listening to the standard MQTT port 1883.
Is this normal and if so why is it listening to this port ?

I also think that this makes that my mqtt service failed to start.
FYI here below the relevant extract from my docker-compose.yml specifying the mqtt service.

  mqtt:
    image: arm32v6/eclipse-mosquitto:1.6.2 #https://hub.docker.com/_/eclipse-mosquitto
    network_mode: host  
    ports:
      - "1883:1883"

and here below the log when I start the mqtt service:

03.10.19 10:01:49 (+0200) Restarting service 'mqtt sha256:30caf0d6fd5119b2aed22be3976c01a67b0d359896c4b249a8a8334b9c6070c1'
03.10.19 10:01:49 (+0200)  mqtt  1570089709: mosquitto version 1.6.2 starting
03.10.19 10:01:49 (+0200)  mqtt  1570089709: Config loaded from /mosquitto/config/mosquitto.conf.
03.10.19 10:01:49 (+0200)  mqtt  1570089709: Opening ipv4 listen socket on port 1883.
03.10.19 10:01:49 (+0200)  mqtt  1570089709: Error: Address in use
03.10.19 10:01:50 (+0200) Service exited 'mqtt sha256:30caf0d6fd5119b2aed22be3976c01a67b0d359896c4b249a8a8334b9c6070c1'

Hi @janvda, as far as I know balena doesn’t do anything special with port 1883 so it doesn’t listen to it by default. I have checked this on my RPi3 running the latest hostOS now and I don’t see the port 1883 listened.

Since your container does use this port, I wonder if that service is not exited fine. Maybe it’s still running although the supervisor thinks it exited. Could you please verify that? (balena ps command would show the running containers)

Next, it’d be useful to look further at the logs to see if there are any errors with stopping the service.

If you could grant us support access and share the device UUID, we’d be glad to take a further look here.

Cheers…

I have rebooted my device and the issue is gone.
So I guess you are right by stating that the mqtt service didn’t exit fine although it was reported as exited in balena dashboard.

Thanks a lot.
Jan.

1 Like

@janvda Did you have a chance to check balena ps output. I wonder if the container was still running as reported by the engine. In such a case, and if you have seen the dashboard reporting it as stopped, there must be some issue with the supervisor…

No, I didn’t do that. I saw your message after I rebooted it. If it reappears I will share the balena ps output.

Thanks. Let us know.

I am having the same issue, however rebooting the device does not fix it
Output of balena ps -a is:

CONTAINER ID   IMAGE                                                            COMMAND                  CREATED          STATUS                            PORTS                                       NAMES
0a97df3ce379   f08ae9919451                                                     "/docker-entrypoint.…"   4 minutes ago    Up 2 minutes                      0.0.0.0:1883->1883/tcp, :::1883->1883/tcp   mqtt-broker_9385585_3116360_7912cd0986ba580605c318c1e581a372
0fb42db7631e   a121ba1af9a7                                                     "/usr/bin/entry.sh .…"   40 minutes ago   Up 2 minutes                                                                  mqtt-sub_9385587_3116360_7912cd0986ba580605c318c1e581a372
31b3d9621696   8d41e6cfd5e5                                                     "/usr/bin/entry.sh .…"   40 minutes ago   Up 2 minutes                                                                  mqtt-pub_9385586_3116360_7912cd0986ba580605c318c1e581a372