发送消息给客户端时提示“客户机未连接”

EQMX版本是5.3,服务器是centos,需求如下:
设备端向emqx指定TOPIC发送查询状态消息,Java端订阅该TOPIC,当收到查询消息时去查询当前设备状态然后转发到设备端订阅的TOPIC,是这么一个流程。
但是当我Java端收到设备端查询消息进行转发后(客户端订阅TOPIC,向该TOPIC发送查询结果),提示客户机未连接 (32104)

如下所示,基本发五条消息只能收到一条,其余消息都是报错客户机未连接

emqx服务端没有相关错误
EMQX 5.3.2 is running now!
2024-04-03T03:23:06.312259+00:00 [warning] msg: http_connector_do_request_failed, mfa: emqx_bridge_http_connector:on_query/3(382), peername: 121.225.189.141:44352, clientid: gateway-system, connector: <<“emqx_authn_http:1”>>, reason: {closed,“The connection was lost.”}
2024-04-03T03:23:06.312525+00:00 [error] msg: send_error, mfa: emqx_resource_buffer_worker:handle_query_result_pure/3(941), peername: 121.225.189.141:44352, clientid: gateway-system, id: <<“emqx_authn_http:1”>>, reason: {recoverable_error,{closed,“The connection was lost.”}}
2024-04-03T03:24:22.141444+00:00 [warning] msg: http_connector_do_request_failed, mfa: emqx_bridge_http_connector:on_query/3(382), peername: 121.225.189.141:43789, clientid: gateway-system, connector: <<“emqx_authn_http:1”>>, reason: timeout
2024-04-03T03:24:22.141723+00:00 [error] msg: send_error, mfa: emqx_resource_buffer_worker:handle_query_result_pure/3(941), peername: 121.225.189.141:43789, clientid: gateway-system, id: <<“emqx_authn_http:1”>>, reason: {recoverable_error,timeout}
2024-04-03T04:30:54.420395+00:00 [warning] msg: http_connector_do_request_failed, mfa: emqx_bridge_http_connector:on_query/3(382), peername: 121.225.189.141:44893, clientid: gateway-system, connector: <<“emqx_authn_http:1”>>, reason: timeout
2024-04-03T04:30:54.420593+00:00 [error] msg: send_error, mfa: emqx_resource_buffer_worker:handle_query_result_pure/3(941), peername: 121.225.189.141:44893, clientid: gateway-system, id: <<“emqx_authn_http:1”>>, reason: {recoverable_error,timeout}

客户机未连接这个错误是 Java 端的提示吗?从 emqx 的日志来看,只有几个 webhook 相关的错误,访问 HTTP 接口超时。

对的,Java端的提示,错误码是32104,emqx的日志跟这个错误应该无关

你打开 debug 日志看看消息流程,可能会有消息丢失的线索。

https://www.emqx.io/docs/zh/latest/observability/log.html#日志

好的,我打开了debug级别的日志并对指定客户端进行了追踪,以下为日志内容,我目前有两个需要给客户端发送消息的地方,第一,客户端订阅了我的topic后我会向该topic发送消息说明客户端状态,第二,客户端向另一个topic发送查询状态消息后我会向客户端订阅的topic发送消息。目前均出现客户机未连接
tracelocal.zip (6.3 KB)

2024-04-03T06:38:58.957608+00:00 [debug] msg: raw_bin_received, mfa: emqx_connection:when_bytes_in/3(778), peername: 121.225.189.141:43233, clientid: abcde123_device12_20240104, bin: 35670035696F742F646576696365732F61626364653132335F64657669636531325F32303234303130342F6465766963652F656E61626C65646DB8007B5C226465766963654E6F5C223A5C2261626364653132335F64657669636531325F32303234303130345C227D, size: 105, type: hex
2024-04-03T06:38:58.958054+00:00 [MQTT] abcde123_device12_20240104@121.225.189.141:43233 msg: mqtt_packet_received, packet: PUBLISH(Q2, R1, D0, Topic=iot/devices/abcde123_device12_20240104/device/enabled, PacketId=28088, Payload={"deviceNo":"abcde123_device12_20240104"})
2024-04-03T06:38:58.958292+00:00 [info] msg: authorization_permission_allowed, mfa: emqx_authz:log_allowed/1(507), peername: 121.225.189.141:43233, clientid: abcde123_device12_20240104, topic: iot/devices/abcde123_device12_20240104/device/enabled, ipaddr: {121,225,189,141}, is_superuser: true, username: <<“test”>>
2024-04-03T06:38:58.958546+00:00 [PUBLISH] abcde123_device12_20240104@121.225.189.141:43233 msg: publish_to, topic: iot/devices/abcde123_device12_20240104/device/enabled, payload: {"deviceNo":"abcde123_device12_20240104"}
2024-04-03T06:38:58.958809+00:00 [MQTT] abcde123_device12_20240104@121.225.189.141:43233 msg: mqtt_packet_sent, packet: PUBREC(Q0, R0, D0, PacketId=28088, ReasonCode=0)
2024-04-03T06:38:58.997822+00:00 [debug] msg: raw_bin_received, mfa: emqx_connection:when_bytes_in/3(778), peername: 121.225.189.141:43233, clientid: abcde123_device12_20240104, bin: 62036DB800, size: 5, type: hex
2024-04-03T06:38:58.998104+00:00 [MQTT] abcde123_device12_20240104@121.225.189.141:43233 msg: mqtt_packet_received, packet: PUBREL(Q1, R0, D0, PacketId=28088, ReasonCode=0)
2024-04-03T06:38:58.998251+00:00 [MQTT] abcde123_device12_20240104@121.225.189.141:43233 msg: mqtt_packet_sent, packet: PUBCOMP(Q0, R0, D0, PacketId=28088, ReasonCode=0)

从日志里看,你这个消息(QoS2) 发到了 emqx,流程是正常的。但没看到后续投递给其他客户端的日志,应该是没有人订阅 iot/devices/abcde123_device12_20240104/device/enabled 这个主题。

哦 你 trace 的是吧,你可以再去 trace 一下订阅者的客户端 ID。

这个是发布的TOPIC,然后我会转发到iot/devices/abcde123_device12_20240104/command/down 这个TOPIC是有订阅的,我提供的日志就是客户端订阅者,没有提供投递的这个客户端的日志,抱歉。

现在貌似正常没有问题了,感谢