Skip to content

Commit 968d8a1

Browse files
Trigger connection recovery when initiator is Library
This happens when we get an I/O exception of a kind, e.g. due to RabbitMQ node becoming unreachable or abruptly shutting down.
1 parent 94266df commit 968d8a1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

projects/client/RabbitMQ.Client/src/client/impl/AutorecoveringConnection.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void init()
9292
var self = this;
9393
ConnectionShutdownEventHandler recoveryListener = (_, args) =>
9494
{
95-
if(args.Initiator == ShutdownInitiator.Peer)
95+
if(ShouldTriggerConnectionRecovery(args))
9696
{
9797
try
9898
{
@@ -111,6 +111,14 @@ public void init()
111111
}
112112
}
113113

114+
protected bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
115+
{
116+
return (args.Initiator == ShutdownInitiator.Peer ||
117+
// happens when EOF is reached, e.g. due to RabbitMQ node
118+
// connectivity loss or abrupt shutdown
119+
args.Initiator == ShutdownInitiator.Library);
120+
}
121+
114122

115123
public event ConnectionShutdownEventHandler ConnectionShutdown
116124
{

0 commit comments

Comments
 (0)