MqttV3 经常自动断开, 重连后客户端经常connection lost 并且带有socketexception. 服务器端某几个clientId连接一直报错, 其他clientid连接正常

请各位大神帮帮忙,被困扰好多天了,头大中~~

环境

java端服务器配置
服务器操作系统:CentOS 7.9 64
docker:emqx版本:emqx:5.0.6
基础配置如下

android端客户端配置
导包如下:
implementation ‘org.eclipse.paho:org.eclipse.paho.android.service:1.1.1’
implementation ‘org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5’
基础配置如下:
mMqttClient = MqttAndroidClient(context, url, clientId)
mMqttClient?.setCallback(mMqttCallback)
mOptions = MqttConnectOptions()
mOptions.isCleanSession = false //是否保持永久订阅
// mOptions.isAutomaticReconnect = true //自动重连
mOptions.maxInflight = 1000 //最大同时传输消息数量
mOptions.userName = username //服务器用户名
mOptions.password = password.toCharArray() //服务器连接密码
// mOptions.maxReconnectDelay = 10000 //重连间隔
mOptions.connectionTimeout = 30 //连接超时时间
mOptions.keepAliveInterval = 4 //心跳时间

目前使用情况:
1.我的服务器配置mqtt后外边有几十台android设备连接中,并正常使用。
2.android设备同款设备

预期行为:
mqtt保持连接并正常使用,各topic正常订阅并可进行Qos为0,1,2的消息收发

我的疑惑?
其中有几台设备时而断开,时而连接成功,断开后重启设备,mqtt重连都可能无效,多次重启之后也会连接成功并正常使用。
并且打印如文末的异常日志(其中某一台)

其他:此设备网络连接正常,可以看视频,浏览网页,http接口请求正常,http服务器连接正常

具体日志:
其中有一台设备 clientID为:ALZ6f6d219a466667f8(此设备id不论如何更改,都会经常性报错)的设备,mqtt连接经常断开,并在android端有两种异常日志,第二种居多,打印日志如下:
第一种--------

05-17 08:29:45.309 2065 2065 W System.err: 已断开连接 (32109) - java.net.SocketException: Connection reset
05-17 08:29:45.309 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.handleRunException(CommsSender.java:194)
05-17 08:29:45.309 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:171)
05-17 08:29:45.309 2065 2065 W System.err: at java.lang.Thread.run(Thread.java:923)
05-17 08:29:45.310 2065 2065 W System.err: Caused by: java.net.SocketException: Connection reset
05-17 08:29:45.310 2065 2065 W System.err: at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:121)
05-17 08:29:45.310 2065 2065 W System.err: at java.net.SocketOutputStream.write(SocketOutputStream.java:161)
05-17 08:29:45.310 2065 2065 W System.err: at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
05-17 08:29:45.310 2065 2065 W System.err: at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
05-17 08:29:45.310 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream.flush(MqttOutputStream.java:49)
05-17 08:29:45.310 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:149)
05-17 08:29:45.310 2065 2065 W System.err: … 1 more

第二种-------

05-17 08:29:51.382 2065 2065 W System.err: 已断开连接 (32109) - java.net.SocketException: Broken pipe
05-17 08:29:51.384 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.handleRunException(CommsSender.java:194)
05-17 08:29:51.384 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:171)
05-17 08:29:51.384 2065 2065 W System.err: at java.lang.Thread.run(Thread.java:923)
05-17 08:29:51.384 2065 2065 W System.err: Caused by: java.net.SocketException: Broken pipe
05-17 08:29:51.384 2065 2065 W System.err: at java.net.SocketOutputStream.socketWrite0(Native Method)
05-17 08:29:51.384 2065 2065 W System.err: at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:117)
05-17 08:29:51.384 2065 2065 W System.err: at java.net.SocketOutputStream.write(SocketOutputStream.java:161)
05-17 08:29:51.384 2065 2065 W System.err: at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
05-17 08:29:51.384 2065 2065 W System.err: at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
05-17 08:29:51.384 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.wire.MqttOutputStream.flush(MqttOutputStream.java:49)
05-17 08:29:51.384 2065 2065 W System.err: at org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:149)
05-17 08:29:51.387 2065 2065 W System.err: … 1 more

服务器日志------
mqtt服务器查询到的日志如下(取其中一小段贴进来,其他的一模一样):

{“log”:“2024-05-17T00:29:33.322323+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.322642542Z”}
{“log”:“2024-05-17T00:29:33.322505+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.322822959Z”}
{“log”:“2024-05-17T00:29:33.322686+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.322967639Z”}
{“log”:“2024-05-17T00:29:33.322843+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.323124643Z”}
{“log”:“2024-05-17T00:29:33.322995+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.323318952Z”}
{“log”:“2024-05-17T00:29:33.323119+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6244, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:33.323666555Z”}
{“log”:“2024-05-17T00:29:39.365087+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28882, peername: 42.233.6.47:6264, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:39.365661301Z”}
{“log”:“2024-05-17T00:29:39.365336+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28883, peername: 42.233.6.47:6264, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:39.365955335Z”}
{“log”:“2024-05-17T00:29:39.365659+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28884, peername: 42.233.6.47:6264, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:39.366581308Z”}
{“log”:“2024-05-17T00:29:39.366121+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6264, reason: receive_maximum_exceeded\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:39.366810244Z”}
{“log”:“2024-05-17T00:29:39.366514+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6264, reason: receive_maximum_exceeded\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:39.366932708Z”}
{“log”:“2024-05-17T00:29:44.956483+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28778, peername: 42.233.6.47:6287\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:44.956997641Z”}
{“log”:“2024-05-17T00:29:44.961883+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28779, peername: 42.233.6.47:6287\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:44.962302532Z”}
{“log”:“2024-05-17T00:29:44.962098+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28780, peername: 42.233.6.47:6287\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:44.962514057Z”}
{“log”:“2024-05-17T00:29:44.962277+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28781, peername: 42.233.6.47:6287\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:44.963152397Z”}
{“log”:“2024-05-17T00:29:45.343275+00:00 [warning] line: 405, message: \u003c\u003c"connection congested: #{buffer =\u003e 4096,clientid =\u003e \u003c\u003c\"ALZ6f6d219a466667f8\"\u003e\u003e,conn_state =\u003e connected,connected_at =\u003e 1715905784904,high_msgq_watermark =\u003e 8192,high_watermark =\u003e 1048576,memory =\u003e 89128,message_queue_len =\u003e 2,peername =\u003e \u003c\u003c\"42.233.6.47:6287\"\u003e\u003e,pid =\u003e \u003c\u003c\"\u003c0.11988.48\u003e\"\u003e\u003e,proto_name =\u003e \u003c\u003c\"MQTT\"\u003e\u003e,proto_ver =\u003e 4,recbuf =\u003e 1837936,recv_cnt =\u003e 541,recv_oct =\u003e 1022593,reductions =\u003e 270"…\u003e\u003e, mfa: emqx_alarm:do_actions/3, msg: alarm_is_activated, name: \u003c\u003c"conn_congestion/ALZ6f6d219a466667f8/admin"\u003e\u003e\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:45.343930518Z”}
{“log”:“2024-05-17T00:29:45.352459+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28889, peername: 42.233.6.47:6287, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:45.353532206Z”}
{“log”:“2024-05-17T00:29:50.999181+00:00 [warning] line: 411, mfa: emqx_alarm:do_actions/3, msg: alarm_is_deactivated, name: \u003c\u003c"conn_congestion/ALZ6f6d219a466667f8/admin"\u003e\u003e\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.000157769Z”}
{“log”:“2024-05-17T00:29:51.045686+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28785, peername: 42.233.6.47:6307\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.046174465Z”}
{“log”:“2024-05-17T00:29:51.056541+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28786, peername: 42.233.6.47:6307\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.057037022Z”}
{“log”:“2024-05-17T00:29:51.056754+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28787, peername: 42.233.6.47:6307\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.057198558Z”}
{“log”:“2024-05-17T00:29:51.056979+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 476, mfa: emqx_channel:handle_in/2, msg: pubrec_packetId_not_found, packetId: 28788, peername: 42.233.6.47:6307\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.057662267Z”}
{“log”:“2024-05-17T00:29:51.119494+00:00 [warning] line: 405, message: \u003c\u003c"connection congested: #{buffer =\u003e 4096,clientid =\u003e \u003c\u003c\"ALZ6f6d219a466667f8\"\u003e\u003e,conn_state =\u003e connected,connected_at =\u003e 1715905790999,high_msgq_watermark =\u003e 8192,high_watermark =\u003e 1048576,memory =\u003e 89216,message_queue_len =\u003e 3,peername =\u003e \u003c\u003c\"42.233.6.47:6307\"\u003e\u003e,pid =\u003e \u003c\u003c\"\u003c0.12008.48\u003e\"\u003e\u003e,proto_name =\u003e \u003c\u003c\"MQTT\"\u003e\u003e,proto_ver =\u003e 4,recbuf =\u003e 369280,recv_cnt =\u003e 13,recv_oct =\u003e 12822,reductions =\u003e 141579,"…\u003e\u003e, mfa: emqx_alarm:do_actions/3, msg: alarm_is_activated, name: \u003c\u003c"conn_congestion/ALZ6f6d219a466667f8/admin"\u003e\u003e\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.120246883Z”}
{“log”:“2024-05-17T00:29:51.274077+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28891, peername: 42.233.6.47:6307, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.274762869Z”}
{“log”:“2024-05-17T00:29:51.274395+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28892, peername: 42.233.6.47:6307, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.275081264Z”}
{“log”:“2024-05-17T00:29:51.274782+00:00 [warning] clientid: ALZ6f6d219a466667f8, line: 757, mfa: emqx_channel:do_publish/3, msg: dropped_qos2_packet, packet_id: 28893, peername: 42.233.6.47:6307, reason: receive_maximum_exceeded, topic: ROBOT/robotPublish/ALZ6f6d219a466667f8\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.275476084Z”}
{“log”:“2024-05-17T00:29:51.275248+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: receive_maximum_exceeded\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.27572914Z”}
{“log”:“2024-05-17T00:29:51.275452+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: receive_maximum_exceeded\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.275743778Z”}
{“log”:“2024-05-17T00:29:51.275688+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.275982258Z”}
{“log”:“2024-05-17T00:29:51.275837+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276898006Z”}
{“log”:“2024-05-17T00:29:51.275990+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.27691431Z”}
{“log”:“2024-05-17T00:29:51.276092+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276920841Z”}
{“log”:“2024-05-17T00:29:51.276191+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276926487Z”}
{“log”:“2024-05-17T00:29:51.276281+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276931305Z”}
{“log”:“2024-05-17T00:29:51.276373+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276936665Z”}
{“log”:“2024-05-17T00:29:51.276429+00:00 [error] clientid: ALZ6f6d219a466667f8, line: 1265, mfa: emqx_channel:handle_info/2, msg: unexpected_sock_close, peername: 42.233.6.47:6307, reason: protocol_error\n”,“stream”:“stdout”,“time”:“2024-05-17T00:29:51.276941918Z”}

从报错来看是客户端的 MQTT 协议报文不对,建议先检查下客户端的代码

找到方法了吗