环境
- EMQX 版本:5.8.9
- 操作系统版本:Alibaba Cloud Linux 3 (Soaring Falcon)
重现此问题的步骤
- 启用Mqttsn网关,配置挂载点:mqttsn/${clientid}/
- 终端连接emqx,ClearSession=false,并订阅mqttsn/设备sn/downlink 主题,Qos=1,然后断开连接,网关中客户端状态显示未连接
- 应用端下发消息到此主题,Qos=1
- 终端再次连接并订阅,Qos=1,始终无法收到应用端下发的消息
预期行为
终端可以收到此消息。
实际行为
一直收不到消息
问题2:
- 终端连接emqx,ClearSession=false,并订阅mqttsn/设备sn/downlink 主题,Qos=1,不断开,网关中客户端状态显示已连接
- 应用端下发消息到此主题,Qos=1
- 终端再次连接并订阅,Qos=1,收到消息,不回复Ack,服务端不重复下发
相关跟踪日志见附件:
ByTopic.zip (632 字节)
PS8J84.zip (4.3 KB)
日志中包含以下错误信息,不知道是否以上两个问题的原因:
2026-08-02T15:20:37.477916+08:00 [error] crasher: initial call: emqx_gateway_conn:init/6, pid: <0.4139.0>, registered_name: , exit: {#{context => function_clause,stacktrace => [{emqx_mqttsn_channel,handle_in,[{mqtt_sn_message,4,{{mqtt_sn_flags,false,0,false,false,false,0},1,60,<<“PS8J84”>>}},{channel,#{cm => <0.3845.0>,gwname => mqttsn},1,false,#{peername => {{116,206,209,187},49153},sockname => {{0,0,0,0},1884},keepalive => 60,peercert => nossl,clientid => <<“PS8J84”>>,proto_ver => <<“1.2”>>,conn_mod => emqx_gateway_conn,connected_at => 1785654635341,proto_name => <<“MQTT-SN”>>,socktype => udp,clean_start => false,expiry_interval => 7200000,disconnected_at => 1785654746955},#{peername => {{116,206,209,187},49153},protocol => ‘mqtt-sn’,username => undefined,listener => ‘mqttsn:udp:default’,clientid => <<“PS8J84”>>,peerhost => {116,206,209,187},enable_authn => true,is_superuser => false,is_bridge => false,zone => default,mountpoint => <<“mqttsn/PS8J84/”>>,sockport => 1884,auth_expire_at => undefined},#{registry => #{name_to_id => #{},last_topic_id => 1024,id_to_name => #{}},session => {session,<<“PS8J84”>>,<<0,6,88,11,30,59,40,189,244,69,0,0,16,43,0,1>>,false,#{<<“mqttsn/PS8J84/downlink”>> => #{nl => 0,is_new => true,qos => 1,rap => 0,rh => 1}},infinity,false,{inflight,1,{0,nil}},{mqueue,true,1000,0,0,disabled,0,{queue,,,0},{shift_opts,10,0},undefined,undefined},1,infinity,#{},100,300000,1785654635342}},{keepalive,30000,3,undefined,30000,90000},undefined,#{clientid => <<“${ConnInfo.clientid}”>>},disconnected,undefined,,undefined,#{keepalive => #Ref<0.994011145.1961099265.41498>,expire_session => #Ref<0.994011145.1961099265.43502>},false,false,}],[{file,“emqx_mqttsn_channel.erl”},{line,451}]},{emqx_gateway_conn,with_channel,3,[{file,“emqx_gateway_conn.erl”},{line,772}]},{emqx_gateway_conn,process_msg,2,[{file,“emqx_gateway_conn.erl”},{line,427}]},{emqx_gateway_conn,process_msg,2,[{file,“emqx_gateway_conn.erl”},{line,433}]},{emqx_gateway_conn,handle_recv,3,[{file,“emqx_gateway_conn.erl”},{line,390}]},{proc_lib,wake_up,3,[{file,“proc_lib.erl”},{line,251}]}],exception => error},[{emqx_gateway_conn,terminate,2,[{file,“emqx_gateway_conn.erl”},{line,615}]},{proc_lib,wake_up,3,[{file,“proc_lib.erl”},{line,251}]}]}, ancestors: [<0.3898.0>,esockd_sup,<0.2446.0>], message_queue_len: 0, messages: , links: [<0.3898.0>], dictionary: [{outgoing_bytes,20},{‘$logger_metadata$’,#{peername => “116.206.209.187:49153”,clientid => <<“PS8J84”>>}},{send_pkt,4},{incoming_bytes,56},{{#{retain => false,action_type => publish,qos => 1},<<“real_data”>>},{allow,1785654676373}},{recv_pkt,5},{authz_cache_size,2},{recv_msg,1},{{#{action_type => subscribe,qos => 1},<<“downlink”>>},{allow,1785654650933}},{authz_keys_q,{[{#{retain => false,action_type => publish,qos => 1},<<“real_data”>>}],[{#{action_type => subscribe,qos => 1},<<“downlink”>>}]}},{guid,{1785654746955992,268577189924907,3}},{incoming_pubs,1}], trap_exit: false, status: running, heap_size: 987, stack_size: 28, reductions: 12034; neighbours:

