EMQ桥接上会自动断开然后一直是连接中的状态

补充说明,这是客户端的桥接信息
环境:docker
版本:5.0.13

配置如下:

错误信息:
2023-01-10T21:18:40.710780+08:00 [warning] line: 421, mfa: emqx_alarm:do_actions/3, msg: alarm_is_deactivated, name: <<“bridge:mqtt:cloud”>>

2023-01-10T21:18:55.538974+08:00 [error] State machine ‘bridge:mqtt:cloud:206’ terminating. Reason: {bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]}. Stack: [{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]. Last event: {{call,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>}},{send_to_remote,#{clientid => <<“example”>>,event => ‘message.publish’,flags => #{retain => false},id => <<“0005F1E8B9CD742E2274000036560000”>>,node => ‘emqx@10.233.90.198’,payload => <<“{"s": "s"}”>>,peerhost => undefined,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673356735509,qos => 1,timestamp => 1673356735509,topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/2312312”>>,username => undefined}}}. State: {connected,#{connect_opts => #{auto_reconnect => true,bridge_mode => true,clean_start => false,clientid => <<“bridge:mqtt:cloud:206:emqx@10.233.90.198”>>,connect_timeout => 30,forwards => #{local => #{topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/#”>>},remote => #{payload => [{var,{var,<<“payload”>>}}],qos => 1,retain => false,topic => [{str,<<“$cloud/#”>>}]}},if_record_metrics => true,keepalive => 60,max_inflight => 32,name => ‘bridge:mqtt:cloud:206’,password => <<“2dbe4d7e12e54fa9aae3d7cbddd62134”>>,proto_ver => v4,reconnect_interval => 10000,retry_interval => 10000,server => {{192,168,3,15},30311},ssl => false,ssl_opts => [{ciphers,[]},{depth,10},{reuse_sessions,true},{secure_renegotiate,true},{user_lookup_fun,{fun emqx_tls_psk:lookup/3,undefined}},{verify,verify_peer},{versions,[‘tlsv1.3’,‘tlsv1.2’,‘tlsv1.1’,tlsv1]}],subscriptions => #{local => #{payload => [{var,{var,<<“payload”>>}}],qos => 1,retain => false,topic => [{str,<<“$edge/#”>>}]},on_message_received => {emqx_connector_mqtt,on_message_received,[<<“$bridges/mqtt:cloud”>>,<<“bridge:mqtt:cloud”>>]},remote => #{qos => 1,topic => <<“$edge/#”>>}},username => <<“0138a17127514fd7bb5c1c70f87e2b3c”>>},connection => #{client_pid => <0.13851.0>,subscriptions => #{local => #{payload => [{var,{var,<<“payload”>>}}],qos => 1,retain => false,topic => [{str,<<“$edge/#”>>}]},on_message_received => {emqx_connector_mqtt,on_message_received,[<<“$bridges/mqtt:cloud”>>,<<“bridge:mqtt:cloud”>>]},remote => #{qos => 1,topic => <<“$edge/#”>>}}},max_inflight => 32,mountpoint => undefined,name => ‘bridge:mqtt:cloud:206’,reconnect_interval => 10000,start_type => manual}}. Client ‘emqx_resource_worker:bridge:mqtt:cloud:3’ stacktrace: [{gen,do_call,4,[{file,“gen.erl”},{line,214}]},{gen_statem,call_dirty,4,[{file,“gen_statem.erl”},{line,693}]},{emqx_resource_worker,apply_query_fun,6,[{file,“emqx_resource_worker.erl”},{line,457}]},{emqx_resource_worker,query_or_acc,3,[{file,“emqx_resource_worker.erl”},{line,309}]}].

2023-01-10T21:18:55.540023+08:00 [error] crasher: initial call: emqx_connector_mqtt_worker:init/1, pid: <0.13850.0>, registered_name: ‘bridge:mqtt:cloud:206’, error: {{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [emqx_connector_mqtt,emqx_connector_sup,<0.2513.0>], message_queue_len: 1, messages: [{disconnected,<0.13851.0>,{shutdown,tcp_closed}}], links: [<0.2515.0>,<0.13911.0>], dictionary: [], trap_exit: true, status: running, heap_size: 28690, stack_size: 29, reductions: 63781; neighbours:

2023-01-10T21:18:55.540418+08:00 [error] Supervisor: {local,emqx_connector_mqtt}. Context: child_terminated. Reason: {{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}. Offender: id=‘bridge:mqtt:cloud:206’,pid=<0.13850.0>.

2023-01-10T21:18:55.540511+08:00 [error] State machine <0.13911.0> terminating. Reason: {{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}. Stack: [{gen_statem,loop_receive,3,[{file,“gen_statem.erl”},{line,1078}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]. State: {connected,{state,undefined,<0.13850.0>,#{disconnected => {fun emqx_connector_mqtt_mod:handle_disconnected/2,[<0.13850.0>]},publish => {fun emqx_connector_mqtt_mod:handle_publish/3,[#{local => #{payload => [{var,{var,<<“payload”>>}}],qos => 1,retain => false,topic => [{str,<<“$edge/#”>>}]},mountpoint => undefined,on_message_received => {emqx_connector_mqtt,on_message_received,[<<“$bridges/mqtt:cloud”>>,<<“bridge:mqtt:cloud”>>]},remote => #{qos => 1,topic => <<“$edge/#”>>}},#{server => <<“192.168.3.15:30311”>>}]}},{192,168,3,15},30311,[],emqtt_sock,#Port<0.325>,[],30000,true,<<“bridge:mqtt:cloud:206:emqx@10.233.90.198”>>,true,<<“0138a17127514fd7bb5c1c70f87e2b3c”>>,#Fun<emqtt_secret.0.70488618>,4,<<“MQTT”>>,60,#Ref<0.4237789018.4220518403.42036>,true,false,false,{mqtt_msg,0,false,false,undefined,undefined,undefined,undefined},#{},[],#{<<“$edge/#”>> => #{nl => 0,qos => 1,rap => 0,rh => 0}},#{max_inflight => 32,sent => #{},seq => 1},#{},true,30000,#Ref<0.4237789018.4220518403.42038>,10000000,undefined,0,3,false,{none,#{max_size => 268435455,strict_mode => false,version => 4}},false,false,undefined,#{count => 0,requests => {[],[]}},#{}}}.

2023-01-10T21:18:55.541188+08:00 [error] crasher: initial call: emqtt:init/1, pid: <0.13911.0>, registered_name: [], exit: {{{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]},[{gen_statem,loop_receive,3,[{file,“gen_statem.erl”},{line,1078}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, ancestors: [‘bridge:mqtt:cloud:206’,emqx_connector_mqtt,emqx_connector_sup,<0.2513.0>], message_queue_len: 0, messages: [], links: [], dictionary: [], trap_exit: true, status: running, heap_size: 10958, stack_size: 29, reductions: 18006; neighbours:

2023-01-10T21:18:55.540640+08:00 [error] bridge: <<“mqtt:cloud”>>, error: {resource_error,#{msg => #{error => {exit,{{{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]},{gen_statem,call,[‘bridge:mqtt:cloud:206’,{send_to_remote,#{clientid => <<“example”>>,event => ‘message.publish’,flags => #{retain => false},id => <<“0005F1E8B9CD742E2274000036560000”>>,node => ‘emqx@10.233.90.198’,payload => <<“{"s": "s"}”>>,peerhost => undefined,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673356735509,qos => 1,timestamp => 1673356735509,topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/2312312”>>,username => undefined}},infinity]}}},id => <<“bridge:mqtt:cloud”>>,name => call_query,request => {send_message,#{clientid => <<“example”>>,event => ‘message.publish’,flags => #{retain => false},id => <<“0005F1E8B9CD742E2274000036560000”>>,node => ‘emqx@10.233.90.198’,payload => <<“{"s": "s"}”>>,peerhost => undefined,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673356735509,qos => 1,timestamp => 1673356735509,topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/2312312”>>,username => undefined}},stacktrace => [{gen,do_call,4,[{file,“gen.erl”},{line,220}]},{gen_statem,call_dirty,4,[{file,“gen_statem.erl”},{line,693}]},{emqx_resource_worker,apply_query_fun,6,[{file,“emqx_resource_worker.erl”},{line,457}]},{emqx_resource_worker,query_or_acc,3,[{file,“emqx_resource_worker.erl”},{line,309}]},{gen_statem,loop_state_callback,11,[{file,“gen_statem.erl”},{line,1203}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]},reason => exception}}, line: 150, mfa: emqx_bridge:send_to_matched_egress_bridges/2, msg: send_message_to_bridge_failed

2023-01-10T21:18:55.540528+08:00 [error] info: #{error => {exit,{{{bad_action_from_state_function,[reply,{<0.13203.0>,#Ref<0.4237789018.4220518402.36887>},{error,{shutdown,tcp_closed}}]},[{gen_statem,loop_actions_list,13,[{file,“gen_statem.erl”},{line,1733}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]},{gen_statem,call,[‘bridge:mqtt:cloud:206’,{send_to_remote,#{clientid => <<“example”>>,event => ‘message.publish’,flags => #{retain => false},id => <<“0005F1E8B9CD742E2274000036560000”>>,node => ‘emqx@10.233.90.198’,payload => <<“{"s": "s"}”>>,peerhost => undefined,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673356735509,qos => 1,timestamp => 1673356735509,topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/2312312”>>,username => undefined}},infinity]}}},id => <<“bridge:mqtt:cloud”>>,name => call_query,request => {send_message,#{clientid => <<“example”>>,event => ‘message.publish’,flags => #{retain => false},id => <<“0005F1E8B9CD742E2274000036560000”>>,node => ‘emqx@10.233.90.198’,payload => <<“{"s": "s"}”>>,peerhost => undefined,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673356735509,qos => 1,timestamp => 1673356735509,topic => <<“$cloud/0138a17127514fd7bb5c1c70f87e2b3c/2312312”>>,username => undefined}},stacktrace => [{gen,do_call,4,[{file,“gen.erl”},{line,220}]},{gen_statem,call_dirty,4,[{file,“gen_statem.erl”},{line,693}]},{emqx_resource_worker,apply_query_fun,6,[{file,“emqx_resource_worker.erl”},{line,457}]},{emqx_resource_worker,query_or_acc,3,[{file,“emqx_resource_worker.erl”},{line,309}]},{gen_statem,loop_state_callback,11,[{file,“gen_statem.erl”},{line,1203}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}, line: 373, mfa: emqx_resource_worker:handle_query_result/4, msg: resource_exception

2023-01-10T21:18:56.098354+08:00 [warning] line: 415, message: <<“resource down: bridge:mqtt:cloud”>>, mfa: emqx_alarm:do_actions/3, msg: alarm_is_activated, name: <<“bridge:mqtt:cloud”>>

2023-01-10T21:18:56.098855+08:00 [error] id: <<“bridge:mqtt:cloud”>>, line: 558, mfa: emqx_resource_manager:handle_connected_health_check/1, msg: health_check_failed, status: connecting

2023-01-10T21:19:10.873740+08:00 [error] bridge: <<“mqtt:cloud”>>, error: {resource_error,#{msg => “resource not connected”,reason => not_connected}}, line: 150, mfa: emqx_bridge:send_to_matched_egress_bridges/2, msg: send_message_to_bridge_failed

以下是报错信息

看日志的话连接应该是被对端断开了,建议在对端排查一下。


这是对端的日志,好像没有什么可用信息

没太理解你的部署形式,EMQX 这边你使用的是 MQTT Bridge 对吗?桥接对象是什么?

两边都是emq的服务器,版本都是5.0.13

建议贴一下被桥接节点的完整日志,你刚提供的日志应该是 WebHook Bridge 打印的,跟你这个问题没什么关系。

这是昨晚客户端一直尝试重连的日志

被桥接的没有任何日志啊 :dizzy_face:

你可以在 MQTT Bridge 连接到对端 EMQX 以后,在客户端列表里面看一下对应的 Client ID 是什么,但是追踪一下这个 Client ID,这样就能获取到详细的日志了。

日志追踪可以参考这个 文档.


现在测试发现,加上出口配置就会一直在连接中的状态(入口配置不影响),请教下这个配置是不是有什么不正确的地方

这是被桥接的错误信息
2023-01-12T17:42:06.912087+08:00 [error] State machine <0.1078.13> terminating. Reason: {function_clause,[{emqx_connector_mqtt_msg,to_remote_msg,[#{clientid => <<“csia09u543u54”>>,event => ‘message.publish’,flags => #{dup => false,retain => false},id => <<“0005F20DEE1C58CA53A70C00721E004D”>>,node => ‘emqx@10.233.90.175’,payload => <<“{\n "deviceNumber": "Z08220501532A1"\n}”>>,peerhost => <<“10.233.92.0”>>,pub_props => #{‘User-Property’ => #{}},publish_received_at => 1673516526885,qos => 1,timestamp => 1673516526885,topic => <<“cloud/test/1”>>,username => <<“csia09u543u54”>>},#{local => #{topic => <<“cloud/test/1”>>},mountpoint => undefined,remote => #{qos => 1,retain => false,topic => [{str,<<“t/test”>>}]}}],[{file,“emqx_connector_mqtt_msg.erl”},{line,66}]},{emqx_connector_mqtt_worker,do_send,2,[{file,“emqx_connector_mqtt_worker.erl”},{line,394}]},{emqx_connector_mqtt_worker,connected,3,[{file,“emqx_connector_mqtt_worker.erl”},{line,304}]},{gen_statem,loop_state_callback,11,[{file,“gen_statem.erl”},{line,1203}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]}. Stack: [{gen_statem,loop_receive,3,[{file,“gen_statem.erl”},{line,1078}]},{proc_lib,init_p_do_apply,3,[{file,“proc_lib.erl”},{line,226}]}]. State: {connected,{state,undefined,<0.963.13>,#{disconnected => {fun emqx_connector_mqtt_mod:handle_disconnected/2,[<0.963.13>]},publish => {fun emqx_connector_mqtt_mod:handle_publish/3,[#{local => #{payload => [{var,{var,<<“payload”>>}}],qos => 1,retain => false,topic => [{str,<<“$edge/#”>>}]},mountpoint => undefined,on_message_received => {emqx_connector_mqtt,on_message_received,[<<“$bridges/mqtt:test”>>,<<“bridge:mqtt:test”>>]},remote => #{qos => 1,topic => <<“$edge/#”>>}},#{server => <<“192.168.3.16:30311”>>}]}},{192,168,3,16},30311,[],emqtt_sock,#Port<0.56881>,[],30000,true,<<“bridge:mqtt:test:61781:emqx@10.233.90.175”>>,true,<<“46dcb9e6355247958713626abdfe72bd”>>,#Fun<emqtt_secret.0.70488618>,4,<<“MQTT”>>,60,#Ref<0.1112073545.3823894531.26049>,true,false,false,{mqtt_msg,0,false,false,undefined,undefined,undefined,undefined},#{},[],#{<<“$edge/#”>> => #{nl => 0,qos => 1,rap => 0,rh => 0}},#{max_inflight => 32,sent => #{},seq => 1},#{},true,30000,#Ref<0.1112073545.3823894531.26051>,15000000,undefined,0,3,false,{none,#{max_size => 268435455,strict_mode => false,version => 4}},false,false,undefined,#{count => 0,requests => {[],[]}},#{}}}.

需要配置消息模板才行

你好,这个 Warning 日志的问题已经在 EMQX v5.0.15 中修复,欢迎下载使用。