emqtt icon indicating copy to clipboard operation
emqtt copied to clipboard

falls when there is no connection

Open heiheshang opened this issue 4 years ago • 3 comments

crasher: initial call: emqtt:init/1, pid: <0.6626.0>, registered_name: [], exit: {{noproc,{gen_statem,call,[<0.6621.0>,ping,infinity]}},[{gen_statem,loop_receive,3,[{file,"gen_statem.erl"},{line,894}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}, ancestors: [scanner_server,scanner_sup,<0.293.0>], message_queue_len: 0, messages: [], links: [], dictionary: [], trap_exit: true, status: running, heap_size: 6772, stack_size: 27, reductions: 13462; neighbours: falls when there is no connection.why it falls when there is no connection? why it is impossible to give the user the option of handling this situation?

heiheshang avatar Aug 25 '19 11:08 heiheshang

Hi, @heiheshang, could you please tell me how do you use emqtt in your case? Please paste the code you give me.

Gilbert Wong On Aug 25, 2019, 7:20 PM +0800, heiheshang [email protected], wrote:

crasher: initial call: emqtt:init/1, pid: <0.6626.0>, registered_name: [], exit: {{noproc,{gen_statem,call,[<0.6621.0>,ping,infinity]}},[{gen_statem,loop_receive,3,[{file,"gen_statem.erl"},{line,894}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}, ancestors: [scanner_server,scanner_sup,<0.293.0>], message_queue_len: 0, messages: [], links: [], dictionary: [], trap_exit: true, status: running, heap_size: 6772, stack_size: 27, reductions: 13462; neighbours: falls when there is no connection.why it falls when there is no connection? why it is impossible to give the user the option of handling this situation? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

gilbertwong96 avatar Aug 25 '19 11:08 gilbertwong96

MQTT=case emqtt:start_link([{owner,self()},{msg_handler,make_msg_handler()}|EConfig]) of {ok, C2} -> case emqtt:connect(C2) of {ok, _Props} -> mqtt_subscribe(C2), erlang:send_after(1000, self(), {tick_1s,C2}), erlang:send_after(5000, self(), {tick_5s,C2}), C2; ErrCon -> erlang:send_after(1000, self(), open_mqtt), logger:error("mqtt connect error ~p",[ErrCon]), {mqtt,no_conected} end; Error -> erlang:send_after(1000, self(), open_mqtt), logger:error("mqtt link error ~p",[Error]), {mqtt,no_conected} end, {mqtt,MQTT}; Error -> logger:error("MQTT ~s",[Error]), {mqtt,no_conected} case emqtt:ping(MQTT) of pong -> print_ping(Win,State#state.ping), NewState=State#state{ping=get_ping(State#state.ping)}, erlang:send_after(1000, self(), {tick_1s,MQTT}); _ -> print_ping(Win,<<"!">>), erlang:send_after(1000, self(), open_mqtt), NewState=State#state{ping= <<"!">>} end,

heiheshang avatar Aug 25 '19 12:08 heiheshang

** Reason for termination == , ** {{{shutdown,tcp_closed},{gen_statem,call,[<0.7627.0>,ping,infinity]}},[{gen,do_call,4,[{file,"gen.erl"},{line,177}]},{gen_statem,call_dirty,4,[{file,"gen_statem.erl"},{line,598}]}, before sending messages, I ping, if the connection is broken, then everything drops

heiheshang avatar Aug 25 '19 12:08 heiheshang