summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Fedotov <hairyhum@gmail.com>2015-07-07 17:43:37 +0300
committerDaniil Fedotov <hairyhum@gmail.com>2015-07-07 17:43:37 +0300
commit516f0cd84464b89beacdc0d3e53ab5cf4c0b3560 (patch)
tree37ed3f896a8dedc169a9d8587a4b370df6858be1
parent8412720c2582a347d02ff04571869de0355178e2 (diff)
downloadrabbitmq-server-git-516f0cd84464b89beacdc0d3e53ab5cf4c0b3560.tar.gz
Log heartbeat timeout in a human friendly way #159
-rw-r--r--src/rabbit_reader.erl29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 6a9eafd9fc..d296c41344 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -273,12 +273,8 @@ start_connection(Parent, HelperSup, Deb, Sock, SockTransform) ->
handshake, 8)]}),
log(info, "closing AMQP connection ~p (~s)~n", [self(), Name])
catch
- Ex -> log(case Ex of
- connection_closed_with_no_data_received -> debug;
- connection_closed_abruptly -> warning;
- _ -> error
- end, "closing AMQP connection ~p (~s):~n~p~n",
- [self(), Name, Ex])
+ Ex ->
+ log_connection_exception(Name, Ex)
after
%% We don't call gen_tcp:close/1 here since it waits for
%% pending output to be sent, which results in unnecessary
@@ -293,6 +289,22 @@ start_connection(Parent, HelperSup, Deb, Sock, SockTransform) ->
end,
done.
+log_connection_exception(Name, Ex) ->
+ Severity = case Ex of
+ connection_closed_with_no_data_received -> debug;
+ connection_closed_abruptly -> warning;
+ _ -> error
+ end,
+ log_connection_exception(Severity, Name, Ex).
+
+log_connection_exception(Severity, Name, {heartbeat_timeout, TimeoutSec}) ->
+ %% Long line to avoid extra spaces and line breaks in log
+ log(Severity, "closing AMQP connection ~p (~s):~nMissed heartbeats from client, timeout: ~ps~n",
+ [self(), Name, TimeoutSec]);
+log_connection_exception(Severity, Name, Ex) ->
+ log(Severity, "closing AMQP connection ~p (~s):~n~p~n",
+ [self(), Name, Ex]).
+
run({M, F, A}) ->
try apply(M, F, A)
catch {become, MFA} -> run(MFA)
@@ -433,9 +445,10 @@ handle_other(handshake_timeout, State) ->
throw({handshake_timeout, State#v1.callback});
handle_other(heartbeat_timeout, State = #v1{connection_state = closed}) ->
State;
-handle_other(heartbeat_timeout, State = #v1{connection_state = S}) ->
+handle_other(heartbeat_timeout,
+ State = #v1{connection = #connection{timeout_sec = T}}) ->
maybe_emit_stats(State),
- throw({heartbeat_timeout, S});
+ throw({heartbeat_timeout, T});
handle_other({'$gen_call', From, {shutdown, Explanation}}, State) ->
{ForceTermination, NewState} = terminate(Explanation, State),
gen_server:reply(From, ok),