]> granicus.if.org Git - ejabberd/commitdiff
Improve logging of idle s2s connections
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 28 Jan 2018 08:10:22 +0000 (11:10 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sun, 28 Jan 2018 08:10:22 +0000 (11:10 +0300)
src/ejabberd_s2s_out.erl
src/xmpp_stream_in.erl
src/xmpp_stream_out.erl

index eb508da1497118352799775d4271f13599855d9d..9abc0d0171da6739656c8a65e5bc94c4d0305e8a 100644 (file)
@@ -254,10 +254,12 @@ handle_recv(El, Pkt, #{server_host := ServerHost} = State) ->
 handle_send(El, Pkt, #{server_host := ServerHost} = State) ->
     ejabberd_hooks:run_fold(s2s_out_handle_send, ServerHost, State, [El, Pkt]).
 
-handle_timeout(#{on_route := Action} = State) ->
+handle_timeout(#{on_route := Action, lang := Lang} = State) ->
     case Action of
        bounce -> stop(State);
-       _ -> send(State, xmpp:serr_connection_timeout())
+       _ ->
+           Txt = <<"Idle connection">>,
+           send(State, xmpp:serr_connection_timeout(Txt, Lang))
     end.
 
 init([#{server := LServer, remote_server := RServer} = State, Opts]) ->
index c27ac5f6bf53250499f2d251dc115028d5238763..6e07e9006cb189b890dac0fd68826ca72a942be3 100644 (file)
@@ -367,11 +367,12 @@ handle_info({'$gen_all_state_event', {xmlstreamcdata, Data}},
     noreply(try Mod:handle_cdata(Data, State)
            catch _:undef -> State
            end);
-handle_info(timeout, #{mod := Mod} = State) ->
+handle_info(timeout, #{mod := Mod, lang := Lang} = State) ->
     Disconnected = is_disconnected(State),
     noreply(try Mod:handle_timeout(State)
            catch _:undef when not Disconnected ->
-                   send_pkt(State, xmpp:serr_connection_timeout());
+                   Txt = <<"Idle connection">>,
+                   send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang));
                  _:undef ->
                    stop(State)
            end);
index 7e79bb80e4fb9031ba4bb3e01f9fb763949dbfeb..ce67d4231c7fd31b84be1779474eeb049d73066d 100644 (file)
@@ -376,11 +376,12 @@ handle_info({'$gen_event', {xmlstreamend, _}}, State) ->
     noreply(process_stream_end({stream, reset}, State));
 handle_info({'$gen_event', closed}, State) ->
     noreply(process_stream_end({socket, closed}, State));
-handle_info(timeout, #{mod := Mod} = State) ->
+handle_info(timeout, #{mod := Mod, lang := Lang} = State) ->
     Disconnected = is_disconnected(State),
     noreply(try Mod:handle_timeout(State)
            catch _:undef when not Disconnected ->
-                   send_pkt(State, xmpp:serr_connection_timeout());
+                   Txt = <<"Idle connection">>,
+                   send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang));
                  _:undef ->
                    stop(State)
            end);