上下线订阅,clientid乱码引起订阅客户端连接断开。

环境信息

  • EMQX 版本:emqx-4.3.5
  • 操作系统及版本:CentOS Linux release 7.3.1611
  • 其他

问题描述

在订阅上下线通知时,clientid出现乱码的情况下,会导致订阅上下线的客户端断开连接,造成数据丢失影响业务,服务器端是否能做容错机制,保持链路正常。

配置文件及日志

2022-06-16T16:01:32.117067+08:00 [info] tds-online@xxx.xxx.xxx.xxx:34658 file: emqx_connection.erl, line: 520, mfa: {emqx_connection,terminate,2}, msg: terminate, pid: <0.31790.3388>, reason: #{context => badarg,exception => error,stacktrace => [{erlang,byte_size,[{error,<<"$SYS/brokers/emqx@127.0.0.1/clients/03">>,<<“öÖÿÿßÿ/connected”>>}],[]},{emqx_frame,serialize_utf8_string,1,[{file,“emqx_frame.erl”},{line,738}]},{emqx_frame,serialize_variable,2,[{file,“emqx_frame.erl”},{line,565}]},{emqx_frame,serialize,2,[{file,“emqx_frame.erl”},{line,505}]},{emqx_frame,serialize_pkt,2,[{file,“emqx_frame.erl”},{line,492}]},{emqx_connection,’-serialize_and_inc_stats_fun/1-fun-2-’,2,[{file,“emqx_connection.erl”},{line,684}]},{lists,map,2,[{file,“lists.erl”},{line,1243}]},{emqx_connection,handle_outgoing,2,[{file,“emqx_connection.erl”},{line,677}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,364}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,370}]},{emqx_connection,handle_recv,3,[{file,[…]},{line,…}]},{proc_lib,wake_up,3,[{file,…},{…}]}]}
2022-06-16T16:01:32.117251+08:00 [debug] {error,“03”,<<“öÖÿÿßÿ”>>}@xxx.xxx.xxx.156:7113 client_id: <<“03öÖÿÿßÿ”>>, file: emqx_cm.erl, line: 114, mfa: {emqx_cm,insert_channel_info,3}, msg: insert_channel_info, pid: <0.31109.3824>
2022-06-16T16:01:32.117462+08:00 [debug] {error,“03”,<<“öÖÿÿßÿ”>>}@xxx.xxx.xxx.156:7113 [MQTT] SEND CONNACK(Q0, R0, D0, AckFlags=0, ReasonCode=0)
2022-06-16T16:01:32.117975+08:00 [debug] 01006450@xxx.xxx.xxx.183:17135 [MQTT] RECV <<192,0>>
2022-06-16T16:01:32.118091+08:00 [debug] 01006450@xxx.xxx.xxx.183:17135 [MQTT] RECV PINGREQ(Q0, R0, D0)
2022-06-16T16:01:32.117481+08:00 [error] tds-online@xxx.xxx.xxx.xxx:34658 crasher: initial call: emqx_connection:init/4, pid: <0.31790.3388>, registered_name: [], error: {badarg,[{erlang,byte_size,[{error,<<"$SYS/brokers/emqx@127.0.0.1/clients/03">>,<<“öÖÿÿßÿ/connected”>>}],[]},{emqx_frame,serialize_utf8_string,1,[{file,“emqx_frame.erl”},{line,738}]},{emqx_frame,serialize_variable,2,[{file,“emqx_frame.erl”},{line,565}]},{emqx_frame,serialize,2,[{file,“emqx_frame.erl”},{line,505}]},{emqx_frame,serialize_pkt,2,[{file,“emqx_frame.erl”},{line,492}]},{emqx_connection,’-serialize_and_inc_stats_fun/1-fun-2-’,2,[{file,“emqx_connection.erl”},{line,684}]},{lists,map,2,[{file,“lists.erl”},{line,1243}]},{emqx_connection,handle_outgoing,2,[{file,“emqx_connection.erl”},{line,677}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,364}]},{emqx_connection,process_msg,2,[{file,[…]},{line,…}]},{emqx_connection,handle_recv,3,[{file,…},{…}]},{proc_lib,wake_up,3,[{…}|…]}]}, ancestors: [<0.1826.0>,<0.1825.0>,esockd_sup,<0.1562.0>], message_queue_len: 0, messages: [], links: [<0.1826.0>], dictionary: [{outgoing_pubs,80},{send_msg,1639},{recv_pkt,2},{rand_seed,{#{bits => 58,jump => #Fun<rand.3.47293030>,next => #Fun<rand.0.47293030>,type => exsss,uniform => #Fun<rand.1.47293030>,uniform_n => #Fun<rand.2.47293030>},[257135643503010146|126280662687120405]}},{’$logger_metadata$’,#{clientid => “tds-online”,peername => “xxx.xxx.xxx.xxx:34658”}},{incoming_bytes,73},{outgoing_bytes,23862},{{subscribe,<<"$SYS/brokers/+/clients/#">>},{allow,1655366490518}},{acl_keys_q,{[{subscribe,<<"$SYS/brokers/+/c"…>>}],[]}},{send_pkt,1641},{guid,{1655366490516132,268565312535598,0}},{acl_cache_size,1}], trap_exit: false, status: running, heap_size: 6772, stack_size: 28, reductions: 13705166; neighbours:
2022-06-16T16:01:32.118177+08:00 [debug] 01006450@xxx.xxx.xxx.183:17135 [MQTT] SEND PINGRESP(Q0, R0, D0)
2022-06-16T16:01:32.118294+08:00 [error] supervisor: ‘esockd_connection_sup - <0.1826.0>’, errorContext: connection_crashed, reason: {badarg,[{erlang,byte_size,[{error,<<"$SYS/brokers/emqx@127.0.0.1/clients/03">>,<<“öÖÿÿßÿ/connected”>>}],[]},{emqx_frame,serialize_utf8_string,1,[{file,“emqx_frame.erl”},{line,738}]},{emqx_frame,serialize_variable,2,[{file,“emqx_frame.erl”},{line,565}]},{emqx_frame,serialize,2,[{file,“emqx_frame.erl”},{line,505}]},{emqx_frame,serialize_pkt,2,[{file,“emqx_frame.erl”},{line,492}]},{emqx_connection,’-serialize_and_inc_stats_fun/1-fun-2-’,2,[{file,“emqx_connection.erl”},{line,684}]},{lists,map,2,[{file,“lists.erl”},{line,1243}]},{emqx_connection,handle_outgoing,2,[{file,“emqx_connection.erl”},{line,677}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,364}]},{emqx_connection,process_msg,2,[{file,[…]},{line,…}]},{emqx_connection,handle_recv,3,[{file,…},{…}]},{proc_lib,wake_up,3,[{…}|…]}]}, offender:

非常感谢你的反馈,我们会尽快修复这一问题