EMQX断开与我java客户端的连接,且重连不上,需要重启java服务器

环境

docker

  • EMQX 版本:最新版
  • 操作系统版本:

重现此问题的步骤

  1. 启动java服务,发消息,但是无人订阅消息,Qos2,自动重连,cleanSession=true
  2. 偶尔同时给几百个topic发送消息,就会导致断连,之后不能重连,只能重启java服务
  3. 只有下面的错误

预期行为

实际行为

2024-05-24T03:31:27.867666+00:00 [error] msg: http_connector_get_status_failed, mfa: emqx_bridge_http_connector:do_get_status/2(535), reason: closed, worker: <0.3130.0>
2024-05-24T03:31:27.868044+00:00 [warning] msg: alarm_is_activated, mfa: emqx_alarm:do_actions/3(418), message: <<“resource down: closed”>>, name: <<“emqx_authn_http:2”>>
2024-05-24T03:31:27.868336+00:00 [warning] msg: health_check_failed, mfa: emqx_resource_manager:handle_connected_health_check/1(893), id: <<“emqx_authn_http:2”>>, status: disconnected
2024-05-24T03:31:42.869515+00:00 [warning] msg: emqx_connector_on_start_already_started, mfa: emqx_bridge_http_connector:start_pool/2(256), pool_name: <<“emqx_authn_http:2”>>
2024-05-24T03:31:42.870638+00:00 [warning] msg: alarm_is_deactivated, mfa: emqx_alarm:do_actions/3(424), name: <<“emqx_authn_http:2”>>
2024-05-24T03:51:08.419752+00:00 [error] supervisor: {esockd_connection_sup,<0.7914684.0>}, errorContext: connection_shutdown, reason: {invalid_proxy_info,<<“GET / HTTP/1.1\r\n”>>}, offender: [{pid,<0.7914684.0>},{name,connection},{mfargs,{emqx_connection,start_link,[#{listener => {tcp,default},limiter => undefined,enable_authn => true,zone => default}]}}]
2024-05-24T03:51:08.474668+00:00 [error] supervisor: {esockd_connection_sup,<0.7914668.0>}, errorContext: connection_shutdown, reason: {invalid_proxy_info,<<“GET / HTTP/1.1\r\n”>>}, offender: [{pid,<0.7914668.0>},{name,connection},{mfargs,{emqx_connection,start_link,[#{listener => {tcp,default},limiter => undefined,enable_authn => true,zone => default}]}}]
2024-05-24T04:15:14.251835+00:00 [error] supervisor: {esockd_connection_sup,<0.7918892.0>}, errorContext: connection_shutdown, reason: {invalid_proxy_info,<<22,3,3,1,2,1,0,0,254,3,3,183,219,231,77,23,174,249,48,9,66,250,136,119,119,38,168,207,210,209,112,200,191,239,140,138,5,60,74,254,240,106,96,0,0,86,192,44,192,43,192,48,192,47,0,159,0,163,0,158,0,162,192,36,192,40,192,35,192,39,0,107,0,106,0,103,0,64,192,46,192,50,192,45,192,49,192,38,192,42,192,37,192,41,192,10>>}, offender: [{pid,<0.7918892.0>},{name,connection},{mfargs,{emqx_connection,start_link,[#{listener => {tcp,default},limiter => undefined,enable_authn => true,zone => default}]}}]
2024-05-24T04:40:00.183929+00:00 [error] supervisor: {esockd_connection_sup,<0.7922084.0>}, errorContext: connection_shutdown, reason: {invalid_proxy_info,<<22,3,3,1,2,1,0,0,254,3,3,140,62,172,115,236,36,192,111,192,16,54,31,94,139,117,160,143,195,182,117,194,3,128,143,229,27,82,41,218,79,107,9,0,0,86,192,44,192,43,192,48,192,47,0,159,0,163,0,158,0,162,192,36,192,40,192,35,192,39,0,107,0,106,0,103,0,64,192,46,192,50,192,45,192,49,192,38,192,42,192,37,192,41,192,10>>}, offender: [{pid,<0.7922084.0>},{name,connection},{mfargs,{emqx_connection,start_link,[#{listener => {tcp,default},limiter => undefined,enable_authn => true,zone => default}]}}]

尝试使用日志追踪抓下这个客户端ID的 DEBUG 日志。首先我们得明确:

  1. Java 客户端断开的原因
  2. 然后在查下 Java 客户端无法连接的问题

我的服务端报这个错,是不是超过了最大限制,丢弃了一些消息?现在看好像是能自动重连
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at org.eclipse.paho.client.mqttv3.internal.CommsSender.handleRunException(CommsSender.java:194) [org.eclipse.paho.client.mqttv3-1.2.2.jar!/:na] at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:171) [org.eclipse.paho.client.mqttv3-1.2.2.jar!/:na]
at java.lang.Thread.run(Thread.java:750) [na:1.8.0_333]
Caused by: java.net.SocketException: Broken pipe (Write failed)
at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_333]
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[na:1.8.0_333]
at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[na:1.8.0_333]
at sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:346) ~[na:1.8.0_333]
at sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1146) ~[na:1.8.0_333]
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.8.0_333]
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) ~[na:1.8.0_333]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream.flush(MqttOutputStream.java:49) ~[org.eclipse.paho.client.mqttv3-1.2.2.jar!/:na]
at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:149) [org.eclipse.paho.client.mqttv3-1.2.2.jar!/:na]
… 1 common frames omitted