Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET client API: HubConnection.Stop() while connecting throws exception #3561

Closed
Niklas-Peter opened this issue Sep 26, 2015 · 1 comment
Closed

Comments

@Niklas-Peter
Copy link

I try to health check a SignalR server from a .NET client. It is sufficient for me to know, whether the SignalR server is able to accept WebSocket connections in general. I do not want to exchange any further messages with the server. If there is any better (performance?) way to healh check the server, please let me know.
The .NET client is the same ASP.NET application, that hosts the SignalR hub, so maybe there is some way to check the SignalR server directly without using the client API?

So far I tried it using this code, but it throws a " System.NullReferenceException", if the timeout exceeded. I could remove this line of code, but I fear, that the connection will remain open until the server reaches a timeout, which would be a waste of resources.

Microsoft.AspNet.SignalR.Client 2.2.0

static bool HealthCheck(string signalRUrl)
{
    var hubConnection = new HubConnection(signalRUrl);
    var task = hubConnection.Start();
    task.Wait(5000);
    if (hubConnection.State != ConnectionState.Connected)
    {
        Console.WriteLine("Could NOT connect to: SignalR hub: timeout of 5 seconds exceeded");
        hubConnection.Stop(new TimeSpan(0, 0, 1)); // throws exception
        return false;
    }
    else
    {
        Console.WriteLine("Connected successfully to SignalR hub");
        hubConnection.Stop(new TimeSpan(0, 0, 1));
        return true;
    }
}
@aspnet-hello
Copy link

This issue has been closed as part of issue clean-up as described in https://blogs.msdn.microsoft.com/webdev/2018/09/17/the-future-of-asp-net-signalr/. If you're still encountering this problem, please feel free to re-open and comment to let us know! We're still interested in hearing from you, the backlog just got a little big and we had to do a bulk clean up to get back on top of things. Thanks for your continued feedback!

vslee added a commit to vslee/ExchangeSharp that referenced this issue Oct 2, 2019
- 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
jjxtra pushed a commit to DigitalRuby/ExchangeSharp that referenced this issue Oct 2, 2019
- 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
vslee added a commit to DigitalRuby/ExchangeSharp that referenced this issue Oct 2, 2019
- 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

(cherry picked from commit 31be2f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants