File tree Expand file tree Collapse file tree 3 files changed +36
-5
lines changed
RabbitMQ.Client/client/impl Expand file tree Collapse file tree 3 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,23 @@ static bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args)
71
71
}
72
72
}
73
73
74
- // happens when EOF is reached, e.g. due to RabbitMQ node
75
- // connectivity loss or abrupt shutdown
76
74
if ( args . Initiator == ShutdownInitiator . Library )
77
75
{
78
- return true ;
76
+ /*
77
+ * https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/826
78
+ * Happens when an AppDomain is unloaded
79
+ */
80
+ if ( args . Exception is ThreadAbortException &&
81
+ args . ReplyCode == Constants . InternalError )
82
+ {
83
+ return false ;
84
+ }
85
+ else
86
+ {
87
+ // happens when EOF is reached, e.g. due to RabbitMQ node
88
+ // connectivity loss or abrupt shutdown
89
+ return true ;
90
+ }
79
91
}
80
92
81
93
return false ;
Original file line number Diff line number Diff line change @@ -53,6 +53,19 @@ private async Task MainLoop()
53
53
await ReceiveLoopAsync ( mainLoopToken )
54
54
. ConfigureAwait ( false ) ;
55
55
}
56
+ #if NETSTANDARD
57
+ catch ( ThreadAbortException taex )
58
+ {
59
+ /*
60
+ * https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/826
61
+ */
62
+ var ea = new ShutdownEventArgs ( ShutdownInitiator . Library ,
63
+ Constants . InternalError ,
64
+ "Thread aborted (AppDomain unloaded?)" ,
65
+ exception : taex ) ;
66
+ HandleMainLoopException ( ea ) ;
67
+ }
68
+ #endif
56
69
catch ( EndOfStreamException eose )
57
70
{
58
71
// Possible heartbeat exception
Original file line number Diff line number Diff line change @@ -116,8 +116,14 @@ protected virtual void Dispose(bool disposing)
116
116
{
117
117
if ( disposing )
118
118
{
119
- _proxyClient . DeleteAsync ( _proxy ) . GetAwaiter ( ) . GetResult ( ) ;
120
- _proxyConnection . Dispose ( ) ;
119
+ try
120
+ {
121
+ _proxyClient . DeleteAsync ( _proxy ) . GetAwaiter ( ) . GetResult ( ) ;
122
+ _proxyConnection . Dispose ( ) ;
123
+ }
124
+ catch
125
+ {
126
+ }
121
127
}
122
128
123
129
_disposedValue = true ;
You can’t perform that action at this time.
0 commit comments