title: SignalR - unable to call server method from external JavaScript client
body: <p>I am learning SignalR. Using a tutorial I managed to create a very simple ASP.NET MVC based SignalR Server. This is the code of the hub:</p>
  
  <pre><code>[HubName("echo")]
  public class EchoHub : Hub
  {
      public void Say(string message)
      {
          Trace.WriteLine(message);
      }
  }
  </code></pre>
  
  <p>This is my Startup file:</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder app)
      {
          app.Map("/signalr", map =&gt;
          {
              map.UseCors(CorsOptions.AllowAll);
              var hubConfiguration = new HubConfiguration
              {
                  EnableJSONP = true
              };
              map.RunSignalR(hubConfiguration);
          });
      }
  }
  </code></pre>
  
  <p>Next I created a HTML/JavaScript based client, that was in the same project as the server code. This client works correctly, when I debug the application, the Output window displays my message. This the code of the first client:</p>
  
  <pre><code>&lt;script src="../Scripts/jquery-1.10.2.min.js"&gt;&lt;/script&gt;
  &lt;script src="../Scripts/jquery.signalR-2.1.2.min.js"&gt;&lt;/script&gt;
  &lt;script src="/signalr/hubs"&gt;&lt;/script&gt;
  &lt;script&gt;
          $(function() {
              var hubProxy = $.connection.echo;
              $.connection.hub.logging = true;
  
              $.connection.hub
                  .start()
                  .done(function () {
                      hubProxy.server.say('Hello SignalR');
                  });
          })
  &lt;/script&gt;
  </code></pre>
  
  <p>The last thing I wanted to do is to create an client in separate project. I changed a little bit the code, mostly by adding the url's of the server. But this client don't work properly. This is the code of the client:</p>
  
  <pre><code>&lt;script src="Scripts/jquery-1.6.4.min.js"&gt;&lt;/script&gt;
  &lt;script src="Scripts/jquery.signalR-2.2.0.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://localhost:51644/signalr/hubs"&gt;&lt;/script&gt;
  &lt;script&gt;
      $(function() {
          $.connection.hub.url = 'http://localhost:51644/signalr';
          var hubProxy = $.connection.echo;
          $.connection.hub.logging = true;
  
          $.connection.hub
              .start()
              .done(function () {
                  hubProxy.server.say('Hello SignalR');
              });
      })
   &lt;/script&gt;
  </code></pre>
  
  <p>The JavaScript don't even enters the function in the done method after starting the connection. But in console on Chrome there are no errors or exceptions being thrown.</p>
  
  <p>So the question is what am I doing wrong in the second client?</p>
  
  <p><strong>EDIT</strong>: I enabled and checked the SignalR client logs in Chrome console. The second client is stoping by step "SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.4&amp;connectionData=%5B%5D'." No errors are returned, everything seems alright, but the client cannot go past this step.</p>
  
  <p><strong>EDIT2</strong>: According to the comment from JF Beaulieu the negotiate return 200 status code, but nothing else. After the negotiate there should be next steps, like invoking Say, but in the external client hangs on the negotiate. I paste here console outputs from the build in and external JavaScript client.</p>
  
  <p>Build in client output:</p>
  
  <p><a href="https://i.stack.imgur.com/e2y82.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e2y82.png" alt="enter image description here"></a></p>
  
  <p>External client output:</p>
  
  <p><a href="https://i.stack.imgur.com/sGsM8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sGsM8.png" alt="enter image description here"></a></p>
  
  <p>The second screenshot shows, that the client stops executing on the negotiate step.</p>
  
  <p>I've also tried the solution of Mareq, but adding the jsonp attribute didn't help.</p>
  
  <p><strong>EDIT3</strong>: I add here a link to my Github repo with this project, the server is in the AspNetServer project and client in JavaScriptClient project, hope that helps:
  <a href="https://github.com/RomanSuska/SignalRSandbox" rel="nofollow noreferrer">https://github.com/RomanSuska/SignalRSandbox</a></p>