My project running in the docker container
, I enter the container ping
IP network is normal,
bash-5.0# ping 172.25.216.186
PING 172.25.216.186 (172.25.216.186): 56 data bytes
64 bytes from 172.25.216.186: seq=0 ttl=64 time=0.099 ms
64 bytes from 172.25.216.186: seq=1 ttl=64 time=0.110 ms
But use mosquitto_sub command
to show the Host is unreachable.
bash-5.0# apk add mosquitto-clients
fetch http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.tuna.tsinghua.edu.cn/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/3) Installing c-ares (1.15.0-r0)
(2/3) Installing mosquitto-libs (1.6.3-r0)
(3/3) Installing mosquitto-clients (1.6.3-r0)
Executing busybox-1.30.1-r2.trigger
OK: 266 MiB in 84 packages
bash-5.0# mosquitto_sub -h 172.25.216.186 -p 1883 -t test -d
Error: Host is unreachable
Strangely enough, I work fine on the host
(base) root@test:~# mosquitto_sub -h 172.25.216.186 -p 1883 -t edge -d
Client mosq-3xlIdUyrnEWBSy8qnL sending CONNECT
Client mosq-3xlIdUyrnEWBSy8qnL received CONNACK (0)
Client mosq-3xlIdUyrnEWBSy8qnL sending SUBSCRIBE (Mid: 1, Topic: edge, QoS: 0, Options: 0x00)
Client mosq-3xlIdUyrnEWBSy8qnL received SUBACK
Subscribed (mid: 1): 0
Intranet IP is obtained as follows
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:16:3e:01:d9:82 brd ff:ff:ff:ff:ff:ff
inet 172.25.216.186/20 brd 172.25.223.255 scope global dynamic eth0
valid_lft 315066103sec preferred_lft 315066103sec
inet6 fe80::216:3eff:fe01:d982/64 scope link
valid_lft forever preferred_lft forever
I don't know what caused this mistake, I hope someone can help me, thank you.
question from:
https://stackoverflow.com/questions/66065244/mosquitto-subscribe-to-test-broker-host-is-unreachable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…