MQTTX 无法连接本地MQTT,可以连WebSocket

环境信息

  • EMQX 版本:emqx-5.0.8
  • 操作系统及版本:windows-amd64
  • 其他

问题描述

MQTTX 可以连接WebSocket,是没问题的;但是连不了mqtt,一直连不上

WebSocket


mqtt


配置文件及日志

[2022-10-19 11:29:15] [INFO] mqtt_test_copy connect close, MQTT.js onClose trigger
[2022-10-19 11:29:18] [INFO] mqtt_test reconnect: 8 times retry
[2022-10-19 11:29:21] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:29:25] [INFO] mqtt_test reconnect: 9 times retry
[2022-10-19 11:29:25] [INFO] mqtt_test reconnect: 9 times retry
[2022-10-19 11:29:28] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:29:33] [INFO] mqtt_test reconnect: 10 times retry
[2022-10-19 11:29:36] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:29:41] [WARN] Connection maxReconnectTimes limit, stop retry
[2022-10-19 11:29:44] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:29:48] [INFO] mqtt_test reconnect: 0 times retry
[2022-10-19 11:29:51] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:29:55] [INFO] mqtt_test reconnect: 1 times retry
[2022-10-19 11:29:58] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:30:02] [INFO] mqtt_test reconnect: 2 times retry
[2022-10-19 11:30:05] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:30:10] [INFO] mqtt_test reconnect: 3 times retry
[2022-10-19 11:30:13] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:30:17] [INFO] mqtt_test reconnect: 4 times retry
[2022-10-19 11:30:20] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:30:25] [INFO] mqtt_test reconnect: 5 times retry
[2022-10-19 11:30:28] [INFO] mqtt_test connect close, MQTT.js onClose trigger
[2022-10-19 11:30:32] [INFO] mqtt_test reconnect: 6 times retry
[2022-10-19 11:30:35] [INFO] mqtt_test connect close, MQTT.js onClose trigger

  1. 先确定网络是不是通的:
    telnet 一下192.168.249.1 1883 和127.0.0.1 1883
    如果是通的。
  2. 把emqx的日志调成debug级别,然后重启。连接时看看emqx的日志有什么异常。

企业微信截图_16661533034629
能ping通,防火墙已关闭,端口没有占用,为啥同样的ip WebSocket的可以?

用ping没什么用的。要用telnet啊

telnet 没有提示
telnet

windows的telnet不会提示的么。我不太清楚。
你telnet 127.0.0.1和192.168.249.1 都是一样的现象么?
你直接对比一下telent18083端口(这个肯定是通的)的现象,如果是一样的。说明就是通的。

如果确定是通的,那上面的第2条看看日志。

127.0.0.1 1883 、192.168.249.1 1883、127.0.0.1 18083 telnet 时都一样,没有提示
127.0.0.1 18083 能打开管理页面

后面改用Docker 镜像,启动 Docker 容器。就能访问了

你好,你这个websocket,是怎么连接上的。我这边正好和你的情况相反,mqtt协议版本3.1.1