1.用的mosquitto1.6.9
2.安装了对应的库,参考该资料 https://blog.csdn.net/u013332124/article/details/79480639
3.配置了config.mk:WITH_WEBSOCKETS:=yes
4.配置了mosquitto.conf:
port 1883
# ws
listener 9001
protocol websockets
allow_anonymous true
#ssl
listener 8883
allow_anonymous true
cafile /root/www.wateriott.com/Apache/1_root_bundle.crt
certfile /root/www.wateriott.com/Apache/2_www.wateriott.com.crt
keyfile /root/www.wateriott.com/Apache/3_www.wateriott.com.key
#wss
listener 8084
protocol websockets
allow_anonymous true
cafile /root/www.wateriott.com/Apache/1_root_bundle.crt
certfile /root/www.wateriott.com/Apache/2_www.wateriott.com.crt
keyfile /root/www.wateriott.com/Apache/3_www.wateriott.com.key
其中ssl证书是通过腾讯云非免申请的
现在的情况是:1883端口可正常使用,8883页没问题,但9001和8084端口服务器的本地telnet localhost xx就不通,远程telnet或在代码里通过ws://xx:9001也是拒绝连接,是怎么回事呢?
[root@VM_0_5_centos mosquitto]# telnet localhost 9001
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
我telnet localhost 1883或8883都没问题,9001换成8083也不行
5.启动命令:mosquitto -c /etc/mosquitto/mosquitto.conf
日志显示:
6.防火墙已关闭
急急急!!非常感谢!