title: What causes SignalR to receive net::ERR_CONNECTION_RESET on connect?
body: <p>I have a simple SingulaR example that I've added to a legacy ASP.Net MVC application.</p>
  
  <p>Here are the various parts:</p>
  
  <p><strong>OWIN Startup class</strong></p>
  
  <pre><code>[assembly: OwinStartup(typeof (Startup))]
  
  namespace MyApp.Web
  {
      public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              app.MapSignalR();
          }
      }
  }
  </code></pre>
  
  <p><strong>SignalR Hub</strong></p>
  
  <pre><code>using System.Collections.Generic;
  using Microsoft.AspNet.SignalR;
  using Microsoft.AspNet.SignalR.Hubs;
  
  namespace MyApp.Web
  {
      [HubName("podService")]
      public class PodServiceHub : Hub
      {
          public PodServiceHub()
          {
              ;
          }
  
          public IEnumerable&lt;string&gt; GetMessages()
          {
              return new[] {"blah", "blah", "blah"};
          }
      }
  }
  </code></pre>
  
  <p><strong>Server-side facade</strong></p>
  
  <pre><code>using Microsoft.AspNet.SignalR;
  using Microsoft.AspNet.SignalR.Hubs;
  
  namespace MyApp.Web
  {
      public class PodService
      {
          PodService(IHubConnectionContext&lt;dynamic&gt; clients)
          {
              Clients = clients;
          }
  
          public PodService()
              : this(GlobalHost.ConnectionManager.GetHubContext&lt;PodServiceHub&gt;().Clients)
          {
          }
  
          IHubConnectionContext&lt;dynamic&gt; Clients { get; set; }
  
          public void SendMessageToClient(string message)
          {
              Clients.All.doSomething(message);
          }
      }
  }
  </code></pre>
  
  <p><strong>Portions of startup Javascript:</strong></p>
  
  <pre><code>    var podService = $.connection.podService;
  
  ...
  
  
  
      $.extend(podService.client, {
          doSomething: function(message) {
              console.log("received message:" + message);
          }
      });
  
  
      // test
      $.connection.hub.start()
          .done(function() {
              podService.server.getMessages()
                  .done(function(messages) {
                      console.log("received message:" + message);
                  });
          });
  </code></pre>
  
  <p>Within one of the controllers called by the first page:</p>
  
  <pre><code>_podService.SendMessageToClient("Hello from the server!");
  </code></pre>
  
  <p>Upon executing the application, the following error is displayed in the console of Chrome's dev tools:</p>
  
  <p>WebSocket connection to 'ws://localhost:62025/signalr/connect?transport=webSockets&amp;clientProtocol=1.5&amp;connectionToken=02LJFqBcRBWKXAOlaSwgMPWG0epV7AFl19gNjFCvA0dxD2QH8%2BC9V028Ehu8fYAFN%2FthPv65JZKfK2MgCEdihCJ0A2dMyENOcdPkhDzEwNB2WQ1X4QXe1fiZAyMbkZ1b&amp;connectionData=%5B%7B%22name%22%3A%22podservice%22%7D%5D&amp;tid=6' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET</p>
  
  <p>After this error, however, the podService.server.getMessages() returns with the message from the server printing ["blah", "blah", "blah"] to the console and subsequently the doSomething client function is invoked printing "received message: Hello from the server!".</p>
  
  <p>The calls from both the client and the server are transmitting data, so this error doesn't appear to be breaking the app.  It definitely seems to be an issue though.  The code above was based upon the sample code generated by the Microsoft.AspNet.SignalR.Sample NuGet package which doesn't display the same behavior.  The only difference I'm aware of between my example and NuGet-based sample is that I've added this to a legacy MVC app vs. a pure OWIN-based app.  Based upon a comment I read <a href="https://stackoverflow.com/questions/26273700/signalr-without-owin">on this SO question</a> this shouldn't be an issue.</p>
  
  <p>So, what's wrong with this example usage and/or what could be causing the connection reset?</p>