This commit is contained in:
Feng 2016-04-29 00:17:07 +08:00
parent 18b8e8195f
commit f5adafe9e2
1 changed files with 6 additions and 1 deletions

View File

@ -79,11 +79,12 @@ init([OriginConn, MqttEnv]) ->
exit({shutdown, Reason})
end,
ConnName = esockd_net:format(PeerName),
Self = self(),
SendFun = fun(Data) ->
try Connection:async_send(Data) of
true -> ok
catch
error:Error -> exit({shutdown, Error})
error:Error -> Self ! {shutdown, Error}
end
end,
PktOpts = proplists:get_value(packet, MqttEnv),
@ -138,6 +139,10 @@ handle_cast(Msg, State) ->
handle_info(timeout, State) ->
shutdown(idle_timeout, State);
%% fix issue #535
handle_info({shutdown, Error}, State) ->
shutdown(Error, State);
%% Asynchronous SUBACK
handle_info({suback, PacketId, GrantedQos}, State) ->
with_proto_state(fun(ProtoState) ->