diff --git a/src/emqx_protocol.erl b/src/emqx_protocol.erl index 01971258c..da7ee88b8 100644 --- a/src/emqx_protocol.erl +++ b/src/emqx_protocol.erl @@ -453,10 +453,11 @@ deliver({connack, ReasonCode}, PState) -> deliver({connack, ReasonCode, SP}, PState) -> send(?CONNACK_PACKET(ReasonCode, SP), PState); -deliver({publish, PacketId, Msg}, PState = #pstate{is_bridge = IsBridge, mountpoint = MountPoint}) -> +deliver({publish, PacketId, Msg}, PState = #pstate{is_bridge = IsBridge, mountpoint = MountPoint}) -> _ = emqx_hooks:run('message.delivered', [credentials(PState)], Msg), - Msg1 = emqx_mountpoint:unmount(MountPoint, clean_retain(IsBridge, Msg)), - send(emqx_packet:from_message(PacketId, Msg1), PState); + Msg1 = emqx_message:update_expiry(Msg), + Msg2 = emqx_mountpoint:unmount(MountPoint, clean_retain(IsBridge, Msg1)), + send(emqx_packet:from_message(PacketId, Msg2), PState); deliver({puback, PacketId, ReasonCode}, PState) -> send(?PUBACK_PACKET(PacketId, ReasonCode), PState);