Ensure the 'CONNACK' and 'DISCONNECT' packets delivered.
This commit is contained in:
parent
52a85d9bb9
commit
03744ead30
|
@ -516,6 +516,9 @@ handle_incoming(Packet = ?PACKET(Type), SuccFun,
|
||||||
State#state{proto_state = NProtoState});
|
State#state{proto_state = NProtoState});
|
||||||
{error, Reason, NProtoState} ->
|
{error, Reason, NProtoState} ->
|
||||||
shutdown(Reason, State#state{proto_state = NProtoState});
|
shutdown(Reason, State#state{proto_state = NProtoState});
|
||||||
|
{error, Reason, OutPacket, NProtoState} ->
|
||||||
|
Shutdown = fun(NewSt) -> shutdown(Reason, NewSt) end,
|
||||||
|
handle_outgoing(OutPacket, Shutdown, State#state{proto_state = NProtoState});
|
||||||
{stop, Error, NProtoState} ->
|
{stop, Error, NProtoState} ->
|
||||||
stop(Error, State#state{proto_state = NProtoState})
|
stop(Error, State#state{proto_state = NProtoState})
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -416,11 +416,15 @@ handle_out({unsuback, PacketId, ReasonCodes}, PState = #protocol{proto_ver = ?MQ
|
||||||
handle_out({unsuback, PacketId, _ReasonCodes}, PState) ->
|
handle_out({unsuback, PacketId, _ReasonCodes}, PState) ->
|
||||||
{ok, ?UNSUBACK_PACKET(PacketId), PState};
|
{ok, ?UNSUBACK_PACKET(PacketId), PState};
|
||||||
|
|
||||||
handle_out({disconnect, ReasonCode}, PState) ->
|
handle_out({disconnect, ReasonCode}, PState = #protocol{proto_ver = ?MQTT_PROTO_V5}) ->
|
||||||
{ok, PState};
|
Reason = emqx_reason_codes:name(ReasonCode),
|
||||||
|
{error, Reason, ?DISCONNECT_PACKET(ReasonCode), PState};
|
||||||
|
|
||||||
|
handle_out({disconnect, ReasonCode}, PState = #protocol{proto_ver = ProtoVer}) ->
|
||||||
|
{error, emqx_reason_codes:name(ReasonCode, ProtoVer), PState};
|
||||||
|
|
||||||
handle_out(Packet, PState) ->
|
handle_out(Packet, PState) ->
|
||||||
io:format("Out: ~p~n", [Packet]),
|
?LOG(error, "Unexpected out:~p", [Packet]),
|
||||||
{ok, PState}.
|
{ok, PState}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -436,6 +436,8 @@ handle_incoming(Packet = ?PACKET(Type), SuccFun,
|
||||||
SuccFun(enqueue(OutPackets, State#state{proto_state = NProtoState}));
|
SuccFun(enqueue(OutPackets, State#state{proto_state = NProtoState}));
|
||||||
{error, Reason, NProtoState} ->
|
{error, Reason, NProtoState} ->
|
||||||
stop(Reason, State#state{proto_state = NProtoState});
|
stop(Reason, State#state{proto_state = NProtoState});
|
||||||
|
{error, Reason, OutPacket, NProtoState} ->
|
||||||
|
stop(Reason, enqueue(OutPacket, State#state{proto_state = NProtoState}));
|
||||||
{stop, Error, NProtoState} ->
|
{stop, Error, NProtoState} ->
|
||||||
stop(Error, State#state{proto_state = NProtoState})
|
stop(Error, State#state{proto_state = NProtoState})
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue