MQTT偶发大量连接无法返回CONNACK问题求助
偶发的Mosquitto连接异常:仅建立TCP连接但未完成MQTT握手
我在网络上搜索许久,但未找到解决方案,这是一个偶发问题。
异常连接的mosquitto.log日志
1677746403: New connection from x.x.x.x:53696 on port 21883. 1677746403: New connection from x.x.x.x:53698 on port 21883. 1677746403: New connection from x.x.x.x:53700 on port 21883. 1677746403: New connection from x.x.x.x:53702 on port 21883. 1677746403: New connection from x.x.x.x:53704 on port 21883. 1677746403: New connection from x.x.x.x:53706 on port 21883. 1677746403: New connection from x.x.x.x:53708 on port 21883. 1677746403: New connection from x.x.x.x:53710 on port 21883. 1677746403: New connection from x.x.x.x:53712 on port 21883. 1677746403: New connection from x.x.x.x:53714 on port 21883. 1677746403: New connection from x.x.x.x:53716 on port 21883. 1677746403: New connection from x.x.x.x:53718 on port 21883. 1677746403: New connection from x.x.x.x:53720 on port 21883.
正常连接的日志
1676530842: New connection from x.x.x.x:56714 on port 21883. 1676530842: New client connected from x.x.x.x:56714 as rec8cee7f3492dbf85f7f483b04541283e (p2, c1, k30). 1676530842: Will message specified (7 bytes) (r0, q2). 1676530842: willTopic 1676530842: Sending CONNACK to rec8cee7f3492dbf85f7f483b04541283e (0, 0)
客户端代码实现
ck(mosquitto_lib_init(), "mosquitto_lib_init()"); m_strId = id; m_strIp = ip; m_nPort = port; m_nKeepAlive = keepTime; if (username.size()) set_name_pwd(username, pwd); m_mosq = mosquitto_new(NULL, true, NULL); mosquitto_connect_callback_set(m_mosq,on_connect); mosquitto_disconnect_callback_set(m_mosq,on_disconnect); mosquitto_publish_callback_set(m_mosq, on_publish); int rec = ck(mosquitto_connect_async(m_mosq,m_strIp.c_str(), m_nPort, m_nKeepAlive), "connect_async");
恳请各位帮忙解答,谢谢!
内容的提问来源于stack exchange,提问作者Mike w
相关产品推荐
相关产品推荐

