0

i am using mosquitto inside docker to act as MQTT server and also the MQTT broker. The docker successfully create the containers for the mosquitto. I follow these step to create the container.

D:\Coding\MQTT\mosquitto>docker network create --subnet=172.16.0.0/24 my_custom_network

D:\Coding\MQTT\mosquitto>docker run -d --name my_mosquitto --network my_custom_network --ip 172.16.0.2 -p 1883:1883 eclipse-mosquitto

I also tried to confirm what ip address it use using this command

D:\Coding\MQTT\mosquitto>docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" my_mosquitto

and it return 192.16.0.2But interestingly, when i tried to use netstat -an | findstr 1883

it return

D:\Coding\MQTT\mosquitto>netstat -an | findstr 1883
  TCP    0.0.0.0:1883           0.0.0.0:0              LISTENING
  TCP    192.168.101.220:56811  172.16.0.2:1883        SYN_SENT
  TCP    [::]:1883              [::]:0                 LISTENING
  TCP    [::1]:1883             [::]:0

After i check on the internet, it mean they are trying to communicate using 172.16.0.2 IP address, but the host failed to response.

Here is the log showed by the docker

2024-08-31 08:13:31 1725063211: mosquitto version 2.0.18 starting
2024-08-31 08:13:31 1725063211: Config loaded from /mosquitto/config/mosquitto.conf.
2024-08-31 08:13:31 1725063211: Starting in local only mode. Connections will only be possible from clients running on this machine.
2024-08-31 08:13:31 1725063211: Create a configuration file which defines a listener to allow remote access.
2024-08-31 08:13:31 1725063211: For more details see https://mosquitto.org/documentation/authentication-methods/
2024-08-31 08:13:31 1725063211: Opening ipv4 listen socket on port 1883.
2024-08-31 08:13:31 1725063211: Opening ipv6 listen socket on port 1883.
2024-08-31 08:13:31 1725063211: mosquitto version 2.0.18 running
2024-08-31 08:28:23 1725064103: mosquitto version 2.0.18 terminating
2024-08-31 08:29:47 1725064187: mosquitto version 2.0.18 starting
2024-08-31 08:29:47 1725064187: Config loaded from /mosquitto/config/mosquitto.conf.
2024-08-31 08:29:47 1725064187: Opening ipv4 listen socket on port 1883.
2024-08-31 08:29:47 1725064187: Opening ipv6 listen socket on port 1883.
2024-08-31 08:29:47 1725064187: mosquitto version 2.0.18 running

and at the mosquitto.conf file, I add

listener 1883
allow_anonymous true

I already try to turnoff the firewall and make the rule to enable inbound and outbound ipaddress using 1883 port.

I also try to disconnect the docker and write this is the cmd

D:\Coding\MQTT\mosquitto>netstat -an | findstr 1883

TCP 192.168.101.220:60409 172.16.0.2:1883 SYN_SENT

is this normal?

Please tell me to resolve this issue.

Any Help appreciated .

0 Answers0