我的 mosquitto 代理当前绑定到端口 1883 上的地址 192.168.2.1。对于在运行 mosquitto 的主机(称为 Linux 计算机)上运行的程序,发布和订阅都可以正常工作,但所有远程计算机都无法使用发布或订阅访问代理(表示远程计算机 Wind10)。
客户端机器 Wind10
当尝试发布 ---.1 或 ---.104 时,它们会产生以下错误,
> .\mosquitto_pub -h 192.168.2.1 -p 1883 -t newsTest -m "remotePayload427" -u redacted -P redacted
Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
> .\mosquitto_pub -h 192.168.2.104 -p 1883 -t newsTest -m "remotePayload427" -u redacted -P redacted
Error: No connection could be made because the target machine actively refused it.
> ipconfig
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::64e1:2bdf:413b:7660%16
IPv4 Address. . . . . . . . . . . : 192.168.2.104
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.2.1
防火墙中转发的端口。
主机。Linux 计算机
Linux 机器正在运行代理。这是其当前配置。
]# more /etc/mosquitto/mosqClean.conf
user mosquit
bind_address 192.168.2.1
port 1883
protocol mqtt
log_dest syslog
log_type all
connection_messages true
log_timestamp true
allow_anonymous false
password_file /etc/mosquitto/plaintext
]# tail -f /var/log/mosquitto.log
2022-09-15T21:21:53.389752-04:00 mtcap mosquitto[23132]: mosquitto version 1.6.14 starting
2022-09-15T21:21:53.392443-04:00 mtcap mosquitto[23132]: Config loaded from /etc/mosquitto/mosqClean.conf.
2022-09-15T21:21:53.395912-04:00 mtcap mosquitto[23132]: Opening ipv4 listen socket on port 1883.
2022-09-15T21:21:53.406287-04:00 mtcap mosquitto[23132]: mosquitto version 1.6.14 running
]# netstat -t
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.2.1:ssh 192.168.2.104:56381 ESTABLISHED
tcp 0 0 192.168.2.1:ssh 192.168.2.104:50539 ESTABLISHED
tcp 0 0 192.168.2.1:ssh 192.168.2.104:50541 ESTABLISHED
]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 192.168.2.1:1883 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN
tcp 0 0 :::domain :::* LISTEN
tcp 0 0 :::ssh :::* LISTEN
tcp 0 0 :::https :::* LISTEN
udp 0 0 0.0.0.0:domain 0.0.0.0:*
udp 0 0 0.0.0.0:bootps 0.0.0.0:*
udp 0 0 :::domain :::*
]# more /etc/network/interfaces
auto lo
iface lo inet loopback
]# ifconfig
br0 Link encap:Ethernet HWaddr 00:08:00:4B:DB:96
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:305983 errors:0 dropped:0 overruns:0 frame:0
TX packets:331765 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24324031 (23.1 MiB) TX bytes:42568583 (40.5 MiB)
eth0 Link encap:Ethernet HWaddr 00:08:00:4B:DB:96
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:306569 errors:0 dropped:577 overruns:0 frame:0
TX packets:335070 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24432998 (23.3 MiB) TX bytes:42747053 (40.7 MiB)
Interrupt:22 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:165515 errors:0 dropped:0 overruns:0 frame:0
TX packets:165515 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19274042 (18.3 MiB) TX bytes:19274042 (18.3 MiB)
请注意,在netstat -t
----.1 上有活动的 ssh 会话。这些会干扰代理吗?