title: SignalR disconnects and does not reconnect
body: <p>Whenever my application gets reset, signalR disconnects but does not reconnect. </p>
  
  <p>I have a long running server task which sends updates to clients when each task is completed. </p>
  
  <pre><code>// inside action executed on every completion of a task
  var h = new ForceHub();
  h.MessageSent(email);
  </code></pre>
  
  <p>above code stops sending updates when application gets reset (i can emulate this problem by touching web.config). </p>
  
  <p>I'd like a way to reconnect to a client. Currently the user has to reload the page for it to get updates again. </p>
  
  <p>Here is my hub definition</p>
  
  <pre><code>public class ForceHub : Hub
  {
      public void MessageSent(string text)
      {
          GetContext().Clients.All.sent(text);
      }
  
      public void UpdateStatus(string msg)
      {
          GetContext().Clients.All.status(msg);
      }
  
      IHubContext GetContext()
      {
          return GlobalHost.ConnectionManager.GetHubContext&lt;ForceHub&gt;();
      }
      public override Task OnConnected()
      {
          try {
              IoC.Resolve&lt;ILogger&gt;().Info("SignalR Connected -----------");
          }catch (Exception){}
  
          return base.OnConnected();
      }
  
      public override Task OnDisconnected()
      {
          try {
              IoC.Resolve&lt;ILogger&gt;().Info("SignalR Disconnected -----------");
          }
          catch (Exception) { }
          return base.OnDisconnected();
      }
  
      public override Task OnReconnected()
      {
          try {
              IoC.Resolve&lt;ILogger&gt;().Info("SignalR Re-Connected -----------");
          }
          catch (Exception) { }
          return base.OnReconnected();
      }
  }
  </code></pre>
  
  <p>I can see <em>Connected</em> and <em>Re-Connected</em> events triggered after startup, however after touching web.config, I don't see any of these events triggered. </p>
  
  <p>i tried catching this on the client, but this event is not tirggered:</p>
  
  <pre><code>$.connection.hub.disconnected(function () {
      console.error('signalR disconnected, retrying connection');
      logError('Signal lost.');
      setTimeout(function () { connection.start(); }, 1000);
  });
  </code></pre>
  
  <p><strong>update</strong> </p>
  
  <p>I also hooked into State Changed event, which does get triggered, but the re-connection attempt below does not work. </p>
  
  <pre><code>        $.connection.hub.stateChanged(function (state) {
              console.debug('signalR state changed', state);
              if (state.newState == 1) {
                  console.debug('restarting');
                  setTimeout(function () { $.connection.hub.start(); }, 1000);
              }
          });
  </code></pre>
  
  <p>this event gets triggered twice: newState is 2 ,and then 1. </p>