user007
user007

Reputation: 1192

Console app SignalR client Disconnect Timeout

I am trying to set Disconnect Timeout to higher value from the default 30s. All examples on web are more JS oriented.

        var hubConnection = new HubConnection("http://localhost:8087");
        var testHubProxy = hubConnection.CreateHubProxy("TestHub");

Error: System.TimeoutException: Couldn't reconnect within the configured timeout of 00:00:30, disconnecting.

This did not work:

        GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(35);

Update: It looks like DisconnectTimeout needs to be set on the server side!?

What is the reason for disallowing different clients to have different Disconnect Timeout?

Upvotes: 0

Views: 1995

Answers (1)

Asim Khan
Asim Khan

Reputation: 572

Disconnect Timeout is configured on server-side. The main reasons could be as follows:

  • We know the server may take some N-time units to respond so that the all clients may be well aware.
  • The server should be pinging the clients for connection at regular times. So the server is aware of clients connection and can manage other hubs and eradicate the expired connections from its connection pool.
  • The client is not supposed to set disconnect timeout because it does not know when could it shutdown e.g. the internet switched off accidentally on client side than the client is not able to tell server that I am not going to connect to you again. Yes but we have some events at client-side which tells it that it is not connected to the signalr hub anymore. Please see the reconnecting and disconnected events.

Summary:

Disconnect timeout is to inform the server that its client is not connected anymore even if it disconnects disgracefully .

Upvotes: 1

Related Questions