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.

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