diff --git a/src/emqx_packet.erl b/src/emqx_packet.erl index 3e5b0ec0c..ba28bddac 100644 --- a/src/emqx_packet.erl +++ b/src/emqx_packet.erl @@ -140,7 +140,7 @@ publish_props(Headers) -> %% @doc Message from Packet -spec(to_message(emqx_types:credentials(), emqx_mqtt_types:packet()) -> emqx_types:message()). -to_message(#{client_id := ClientId, username := Username}, +to_message(#{client_id := ClientId, username := Username, peername := Peername}, #mqtt_packet{header = #mqtt_packet_header{type = ?PUBLISH, retain = Retain, qos = QoS, @@ -150,7 +150,8 @@ to_message(#{client_id := ClientId, username := Username}, payload = Payload}) -> Msg = emqx_message:make(ClientId, QoS, Topic, Payload), Msg#message{flags = #{dup => Dup, retain => Retain}, - headers = merge_props(#{username => Username}, Props)}. + headers = merge_props(#{username => Username, + peername => Peername}, Props)}. -spec(will_msg(#mqtt_packet_connect{}) -> emqx_types:message()). will_msg(#mqtt_packet_connect{will_flag = false}) -> diff --git a/src/emqx_stats.erl b/src/emqx_stats.erl index 926db5b04..bec56f142 100644 --- a/src/emqx_stats.erl +++ b/src/emqx_stats.erl @@ -228,7 +228,7 @@ handle_info({timeout, TRef, tick}, State = #state{timer = TRef, updates = Update {noreply, start_timer(State#state{updates = Updates1}), hibernate}; handle_info(Info, State) -> - ?LOG("error, [Stats] Unexpected info: ~p", [Info]), + ?LOG(error, "[Stats] Unexpected info: ~p", [Info]), {noreply, State}. terminate(_Reason, #state{timer = TRef}) -> diff --git a/src/emqx_ws_connection.erl b/src/emqx_ws_connection.erl index e3094e11c..92ae6a7dd 100644 --- a/src/emqx_ws_connection.erl +++ b/src/emqx_ws_connection.erl @@ -113,7 +113,7 @@ call(WSPid, Req) when is_pid(WSPid) -> %%------------------------------------------------------------------------------ init(Req, Opts) -> - IdleTimeout = proplists:get_value(idle_timeout, Opts, 60000), + IdleTimeout = proplists:get_value(idle_timeout, Opts, 7200000), DeflateOptions = maps:from_list(proplists:get_value(deflate_options, Opts, [])), MaxFrameSize = case proplists:get_value(max_frame_size, Opts, 0) of 0 -> infinity; diff --git a/test/emqx_packet_SUITE.erl b/test/emqx_packet_SUITE.erl index 4cb87bd18..07fb6c58d 100644 --- a/test/emqx_packet_SUITE.erl +++ b/test/emqx_packet_SUITE.erl @@ -100,8 +100,13 @@ packet_message(_) -> Msg = emqx_message:make(<<"clientid">>, ?QOS_0, <<"topic">>, <<"payload">>), Msg2 = emqx_message:set_flag(retain, false, Msg), Pkt = emqx_packet:from_message(10, Msg2), - Msg3 = emqx_message:set_header(username, "test", Msg2), - Msg4 = emqx_packet:to_message(#{client_id => <<"clientid">>, username => "test"}, Pkt), + Msg3 = emqx_message:set_header( + peername, {{127,0,0,1}, 9527}, + emqx_message:set_header(username, "test", Msg2) + ), + Msg4 = emqx_packet:to_message(#{client_id => <<"clientid">>, + username => "test", + peername => {{127,0,0,1}, 9527}}, Pkt), Msg5 = Msg4#message{timestamp = Msg3#message.timestamp, id = Msg3#message.id}, Msg5 = Msg3.