0
votes

When I am going to use it's for cross domain then i am getting error message when i call start() function. Error in jquery.signalR-2.0.2.min.js. Error message is "Uncaught Error: SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. ."

I am using server side code

Startup.cs class code is:

       [assembly: OwinStartup(typeof(SignalRNew.Startup))]

       namespace SignalRNew
       {
           public class Startup
           {
                public void Configuration(IAppBuilder app)
                {
                   app.Map("/signalr", map =>
                   {
                       map.UseCors(CorsOptions.AllowAll);
                       var hubConfiguration = new HubConfiguration
                       {
                            EnableJSONP = true
                        };
                       map.RunSignalR(hubConfiguration);
                   });
                }
             }
          }

I am using client side script is:

  <!DOCTYPE html>
     <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title></title>
         <script src="/Scripts/jquery-1.6.4.min.js"></script>
         <script src="/Scripts/jquery.signalR-2.0.2.min.js"></script>
      </head>
    <body>
      <div></div>
      <script type="text/javascript">
        $.connection.hub.url = 'http:\\localhost:2100\signalr';
        $.connection.hub.start().done(function () {
           alert('Now connected');
        });
      </script>
     </body>
     </html>

 kindly reply...
2

2 Answers

0
votes

Try to enable the logging in the client side, and look for error messages or warnings:

http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-javascript-client#logging

Enable logging (with the generated proxy)

$.connection.hub.logging = true;
$.connection.hub.start();

Enable logging (without the generated proxy)

var connection = $.hubConnection();
connection.logging = true;
connection.start();
0
votes

Please try creating the proxy by following steps.

var connection=$.hubConnection();
var proxy=connection.createHubProxy("hubName");
connection.start().done(function () {
       alert('Now connected');
    });

You have connected the url without giving the hub name .That may be the problem.