Skip to content

Commit 2288bd6

Browse files
committed
RE1-T117 PR#408 fixes
1 parent eeb0ebf commit 2288bd6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Providers/Resgrid.Providers.Bus.Rabbit/RabbitConnection.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,13 @@ public static async Task<IConnection> CreateConnection(string clientName)
182182
if (_connection == null)
183183
await VerifyAndCreateClients(clientName);
184184

185-
if (!_connection.IsOpen)
185+
// _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)
186188
{
187-
await _connection.DisposeAsync();
189+
if (_connection != null)
190+
await _connection.DisposeAsync();
191+
188192
_connection = null;
189193
_factory = null;
190194
RaiseConnectionReset();

0 commit comments

Comments
 (0)