Skip to content

Commit 31be2f6

Browse files
vsleejjxtra
authored andcommitted
workaround SignalR HubConnection.Stop() bug (#456)
- bug in SignalR where Stop() throws a NRE if it times out - SignalR/SignalR#3561 - also handle case where trying to dispose of a HubConnection where the Transport is null
1 parent d577c7e commit 31be2f6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ExchangeSharp/Utility/SignalrManager.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,15 @@ public async Task StartAsync()
677677
/// </summary>
678678
public void Stop()
679679
{
680-
hubConnection.Stop(TimeSpan.FromSeconds(0.1));
681-
}
680+
try
681+
{
682+
hubConnection.Stop(TimeSpan.FromSeconds(0.1));
683+
}
684+
catch (NullReferenceException)
685+
{ // bug in SignalR where Stop() throws a NRE if it times out
686+
// https://github.com/SignalR/SignalR/issues/3561
687+
}
688+
}
682689

683690
/// <summary>
684691
/// Finalizer
@@ -700,7 +707,7 @@ public void Dispose()
700707
disposed = true;
701708
try
702709
{
703-
hubConnection.Transport.Dispose();
710+
hubConnection.Transport?.Dispose();
704711
hubConnection.Dispose();
705712
}
706713
catch

0 commit comments

Comments
 (0)