EMQX消息延迟问题

设备向EMQX发布消息,EMQX日志
2024-05-21T12:57:22.234543+00:00 [debug] msg: raw_bin_received, mfa: emqx_connection:when_bytes_in/3, line: 771, peername: 39.144.5.99:30419, clienti
d: 0QhWWpMwqnP/123001000398, bin: 30DF0100372F7379732F3051685757704D77716E502F3132333030313030303339382F7468696E672F6576656E742F70726F70657274792F706
F73747B226964223A22323130222C2276657273696F6E223A22312E30222C22706172616D73223A7B225561223A3232362E34352C225562223A3232382E35333939392C225563223A3232
382E33392C2252737369223A31322C224D444944223A3235352C224261756452617465223A332C22475750757368496E74657276616C223A31352C2250757368496E74657276616C223A3
3307D2C22737973223A7B2261636B223A317D7D, size: 226, type: hex
2024-05-21T12:57:22.234928+00:00 [debug] msg: mqtt_packet_received, mfa: emqx_connection:handle_msg/2, line: 567, peername: 39.144.5.99:30419, client
id: 0QhWWpMwqnP/123001000398, packet: PUBLISH(Q0, R0, D0, Topic=/sys/0QhWWpMwqnP/123001000398/thing/event/property/post, PacketId=undefined, Payload=
{“id”:“210”,“version”:“1.0”,“params”:{“Ua”:226.45,“Ub”:228.53999,“Uc”:228.39,“Rssi”:12,“MDID”:255,“BaudRate”:3,“GWPushInterval”:15,“PushInterval”:30}
,“sys”:{“ack”:1}}), tag: MQTT
2024-05-21T12:57:22.235310+00:00 [debug] msg: publish_to, mfa: emqx_trace:publish/1, line: 73, peername: 39.144.5.99:30419, clientid: 0QhWWpMwqnP/123
001000398, topic: /sys/0QhWWpMwqnP/123001000398/thing/event/property/post, payload: {“id”:“210”,“version”:“1.0”,“params”:{“Ua”:226.45,“Ub”:228.53999,
“Uc”:228.39,“Rssi”:12,“MDID”:255,“BaudRate”:3,“GWPushInterval”:15,“PushInterval”:30},“sys”:{“ack”:1}}, tag: PUBLISH
2024-05-21T12:57:22.235797+00:00 [debug] msg: mqtt_packet_sent, mfa: emqx_connection:serialize_and_inc_stats_fun/1, line: 870, peername: 172.29.240.2
:38810, clientid: mqtt_46301, packet: PUBLISH(Q0, R0, D0, Topic=/sys/0QhWWpMwqnP/123001000398/thing/event/property/post, PacketId=undefined, Payload=
{“id”:“210”,“version”:“1.0”,“params”:{“Ua”:226.45,“Ub”:228.53999,“Uc”:228.39,“Rssi”:12,“MDID”:255,“BaudRate”:3,“GWPushInterval”:15,“PushInterval”:30}
,“sys”:{“ack”:1}}), tag: MQTT

我们的消费者收到时间
2024-05-21 20:59:17 | MQTT Call: mqtt_46301 | INFO | com.jybfgs.iotx.mqtt.handler.MessageInBoundHandler | mqtt original topic /sys/0QhWWpMwqnP/123001000398/thing/event/property/post, message {“id”:“210”,“version”:“1.0”,“params”:{“Ua”:226.45,“Ub”:228.53999,“Uc”:228.39,“Rssi”:12,“MDID”:255,“BaudRate”:3,“GWPushInterval”:15,“PushInterval”:30},“sys”:{“ack”:1}}

两者为何差了2分钟。我们的消费者是直接注册到EMQX的

你好,从日志看是 EMQX 这边的发送消息的日式时间 和 消费者这边的接收到消息的日志时间,差2分钟。

这种一般有几种可能:

  1. 俩个软件的系统时间不一致。
  2. 客户端程序从消息在网上接收成功,到日志打印输出这段代码里,可能存在任务的阻塞。
  3. EMQX 发送存在阻塞。

1 需要检查下你的俩个机器。2,3可以直接通过网络抓包,看消息从接收,到到底你的消费者中间是否有大的时间差,如果没有,那就是原因2导致的。如果有就是3导致的

2024-05-22 10:14:46 | MQTT Snd: mqtt_19328 | ERROR | o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter | Lost connection: Connection lost; retrying…
2024-05-22 10:31:46 | MQTT Snd: mqtt_19328 | ERROR | o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter | Lost connection: Connection lost; retrying…
2024-05-22 10:49:10 | MQTT Snd: mqtt_19328 | ERROR | o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter | Lost connection: Connection lost; retrying…
2024-05-22 11:10:58 | MQTT Snd: mqtt_19328 | ERROR | o.s.i.m.i.MqttPahoMessageDrivenChannelAdapter | Lost connection: Connection lost; retrying…

这种报错是什么原因导致的,最近数据量上来后,报的很频繁

3一般怎么优化的