none
SignalR 404 error when trying to negotiate RRS feed

  • Question

  • So I am very new to SignalR, in fact I've only been using it for a couple of days now. Anyway, I am getting the error below when my application first starts up:

    The code for the application in question is located in two projects, a Web API and a Single Page Application (SPA). The first one has my backend code (C#) and the second one my client-side code (AngularJS). I think the problem might be due to the fact that the projects in question run on different ports. The Web API, where my SignalR hub lives, is on port 60161 and the SPA is on 60813. My hub is declared like so:

    public class ReportHub : Hub
    {
        public void SendReportProgress(IList<ReportProgress> reportProgress)
        {                
            this.Clients.All.broadcastReportProgress(reportProgress);
        }
    
        public override Task OnConnected()
        {
            this.Clients.All.newConnection();
    
            return base.OnConnected();
        }
    }

    and then in my Startup.cs file for my Web API I initialize SignalR like this:

    public void Configuration(IAppBuilder app)
    {           
            HttpConfiguration config = new HttpConfiguration();
            config.Services.Replace(typeof(IHttpControllerActivator), new NinjectFactory());
            config.MessageHandlers.Add(new MessageHandler());
    
            //set up OAuth and Cors
            this.ConfigureOAuth(app);
            config.EnableCors();
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
    
            // Setting up SignalR
            app.Map("/signalr", map =>
            {
                map.UseCors(CorsOptions.AllowAll);
                map.RunSignalR(new HubConfiguration { EnableJSONP = true });
            });
    
            //set up json formatters
            FormatterConfig.RegisterFormatters(config.Formatters);
    
            WebApiConfig.Register(config);
                
            app.UseWebApi(config);
    }

    For my client-side code I use an Angular SignalR API called angular-signalr-hub (installed it from NuGet). The client-side follows:

    angular
        .module("mainApp")
        .factory("reportHubService", ["$rootScope", "Hub", reportHubService]);
    
        /// The factory function
        function reportHubService($rootScope, Hub) {
            var vm = this;
            vm.reportName = "None";
    
            // Setting up the SignalR hub
            var hub = new Hub("reportHub", {
                listeners: {
                    'newConnection': function(id) {
                        vm.reportName = "SignalR connected!";
                        $rootScope.$apply();
                    },
                    'broadcastReportProgress': function (reportProgress) {
                        vm.reportName = reportProgress.reportName;
                        $rootScope.$apply();
                    }
                },
                errorHandler: function(error) {
                    
                },
                hubDisconnected: function () {
                    if (hub.connection.lastError) {
                        hub.connection.start();
                    }
                },
                transport: 'webSockets',
                logging: true
                //rootPath: 'http://localhost:60161/signalr'
            });

    I did some googling yesterday and one of the suggestions I came upon was to set the SignalR URL to the one of my Web API, which I did (the commented out line above). When I uncomment the line above, that does seem to do something because if I now go to http://localhost:60161/signalr/hubs in my browser, it does show me the dynamically generated proxy file:

    and when I run my application now I no longer get the error above, but now it doesn't seem to connect. It gets to the negotiate line and it stops there:


    I think it should look like this (this is from a SignalR tutorial I found):

    In addition, none of my listeners (declared in my Angular code above) get called, so something is still now working quite right. There should be more lines in the log to the effect that connection was successfully established, etc. What could be the problem here?








    • Edited by lou_1 Friday, May 27, 2016 3:22 PM Clarification
    • Moved by DotNet Wang Thursday, June 2, 2016 2:48 AM asp.net related
    Friday, May 27, 2016 2:27 PM

Answers

  • Hi lou_1,

    >>"I want to move it to the ASP.NET SignalR forum. How can i do that?"

    Sorry, we can't do this because they are different sites. I suggest you repost it on ASP.NET SignalR forum.

    Thanks for your understanding.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by lou_1 Tuesday, August 1, 2017 4:48 PM
    Saturday, May 28, 2016 6:01 AM

All replies

  • It seems I posted this in the wrong forum. I want to move it to the ASP.NET SignalR forum. How can i do that?
    Friday, May 27, 2016 3:56 PM
  • Hi lou_1,

    >>"I want to move it to the ASP.NET SignalR forum. How can i do that?"

    Sorry, we can't do this because they are different sites. I suggest you repost it on ASP.NET SignalR forum.

    Thanks for your understanding.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by lou_1 Tuesday, August 1, 2017 4:48 PM
    Saturday, May 28, 2016 6:01 AM