@@ -422,6 +422,7 @@ start_connection(Parent, HelperSup, Deb, Sock) ->
422
422
log_connection_exception (Name , Ex ) ->
423
423
Severity = case Ex of
424
424
connection_closed_with_no_data_received -> debug ;
425
+ {connection_closed_abruptly , _ } -> warning ;
425
426
connection_closed_abruptly -> warning ;
426
427
_ -> error
427
428
end ,
@@ -431,6 +432,17 @@ log_connection_exception(Severity, Name, {heartbeat_timeout, TimeoutSec}) ->
431
432
% % Long line to avoid extra spaces and line breaks in log
432
433
log (Severity , " closing AMQP connection ~p (~s ):~n missed heartbeats from client, timeout: ~p s~n " ,
433
434
[self (), Name , TimeoutSec ]);
435
+ log_connection_exception (Severity , Name , {connection_closed_abruptly ,
436
+ # v1 {connection = # connection {user = # user {username = Username },
437
+ vhost = VHost }}}) ->
438
+ log (Severity , " closing AMQP connection ~p (~s , vhost: '~s ', user: '~s '):~n client unexpectedly closed TCP connection~n " ,
439
+ [self (), Name , VHost , Username ]);
440
+ % % when client abruptly closes connection before connection.open/authentication/authorization
441
+ % % succeeded, don't log username and vhost as 'none'
442
+ log_connection_exception (Severity , Name , {connection_closed_abruptly , _ }) ->
443
+ log (Severity , " closing AMQP connection ~p (~s ):~n client unexpectedly closed TCP connection~n " ,
444
+ [self (), Name ]);
445
+ % % old exception structure
434
446
log_connection_exception (Severity , Name , connection_closed_abruptly ) ->
435
447
log (Severity , " closing AMQP connection ~p (~s ):~n client unexpectedly closed TCP connection~n " ,
436
448
[self (), Name ]);
@@ -528,7 +540,7 @@ stop(tcp_healthcheck, State) ->
528
540
throw (connection_closed_with_no_data_received );
529
541
stop (closed , State ) ->
530
542
maybe_emit_stats (State ),
531
- throw (connection_closed_abruptly );
543
+ throw ({ connection_closed_abruptly , State } );
532
544
stop (Reason , State ) ->
533
545
maybe_emit_stats (State ),
534
546
throw ({inet_error , Reason }).
@@ -1138,7 +1150,7 @@ handle_method0(MethodName, FieldsBin,
1138
1150
State )
1139
1151
catch throw :{inet_error , E } when E =:= closed ; E =:= enotconn ->
1140
1152
maybe_emit_stats (State ),
1141
- throw (connection_closed_abruptly );
1153
+ throw ({ connection_closed_abruptly , State } );
1142
1154
exit :# amqp_error {method = none } = Reason ->
1143
1155
handle_exception (State , 0 , Reason # amqp_error {method = MethodName });
1144
1156
Type :Reason ->
0 commit comments