项目连接emqx集群服务的虚拟IP时,启动可以正常连接并订阅主题成功,过一分钟后就断掉连,后续一直无法连接
改为集群中的单点ip没问题
用什么搞的虚拟 IP? F5 还是?
麻烦提供一下 emqx 的 debug 日志。
根据官方配置的Haproxy 的虚拟IP,
日志如下:
2024-12-10T09:54:43+08:00 [MQTT] MQTT_FX_Client_Local@192.168.66.30:44122 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0),ClientId=MQTT_FX_Client_Local, ProtoName=MQTT, ProtoVsn=4, CleanStart=true, KeepAlive=60, Username=canal, Password=******
2024-12-10T09:54:43.323288+08:00 [debug] client_id: <<“MQTT_FX_Client_Local”>>, clientid: MQTT_FX_Client_Local, line: 155, mfa: emqx_cm:insert_channel_info/3, msg: insert_channel_info, peername: 192.168.66.30:44122
2024-12-10T09:54:43+08:00 [MQTT] MQTT_FX_Client_Local@192.168.66.30:44122 msg: mqtt_packet_sent, packet: CONNACK(Q0, R0, D0),AckFlags=0, ReasonCode=0
2024-12-10T09:55:43+08:00 [SOCKET] MQTT_FX_Client_Local@192.168.66.30:44122 msg: emqx_connection_terminated, reason: {shutdown,tcp_closed}
2024-12-10T09:55:43.325707+08:00 [info] clientid: MQTT_FX_Client_Local, line: 636, mfa: emqx_connection:terminate/2, msg: terminate, peername: 192.168.66.30:44122, reason: {shutdown,tcp_closed}
这个是 haproxy 把他断开的。你一分钟没发任何包,被 haproxy 认为没心跳断开了。调高一点心跳:
#option dontlognull
timeout connect 10000
# timeout > mqtt's keepalive * 1.2
timeout client 240s
timeout server 240s
非常感谢您!调整了这些参数目前不再有断开现象了