We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eeb0ebf commit 2288bd6Copy full SHA for 2288bd6
1 file changed
Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs
@@ -182,9 +182,13 @@ public static async Task<IConnection> CreateConnection(string clientName)
182
if (_connection == null)
183
await VerifyAndCreateClients(clientName);
184
185
- if (!_connection.IsOpen)
+ // _connection can still be null here if VerifyAndCreateClients failed to connect (e.g. primary
186
+ // host down and no fallback host configured), so guard before accessing IsOpen to avoid an NRE.
187
+ if (_connection == null || !_connection.IsOpen)
188
{
- await _connection.DisposeAsync();
189
+ if (_connection != null)
190
+ await _connection.DisposeAsync();
191
+
192
_connection = null;
193
_factory = null;
194
RaiseConnectionReset();
0 commit comments