SignalR unable to connect client to server #202

Closed
opened 2026-01-29 16:33:33 +00:00 by claunia · 0 comments
Owner

Originally created by @Shimmy96 on GitHub (Aug 8, 2018).

Currently working on updating my Angular6 SPA application to use real-time sockets via SignalR. Right now, when the client tries to establish a connection with the server (which is an ASP.NET Core application hosted with Electron.NET), the client fails to 'negotiate' with the server. Are there any constraints on the Electron.NET side that is blocking incoming client connections?

Angular connection:

this._hubConnection = new signalR.HubConnectionBuilder()
      .withUrl(`http://localhost:1337/socket/chatHub`)
      .configureLogging(signalR.LogLevel.Trace)
      .build();

    this._hubConnection.start().catch(err => console.error(err.toString()));

.NET Core 2.1 Server side setup for SignalR:

 // Configure()
            app.UseSignalR(routes =>
            {
                routes.MapHub<ChatHub>("/socket/chatHub");
            });

// ConfigureServices()
services.AddCors(o =>
            {
                o.AddPolicy("CorsPolicy", b =>
                {
                    b.AllowAnyHeader()
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });
            services.AddSignalR();
            services.AddScoped<ChatHub>();

Error in console:
Debug: Starting HubConnection. Utils.js:158 Debug: Starting connection with transfer format 'Text'. Utils.js:158 Debug: Sending negotiation request: http://localhost:1337/chatHub/negotiate chatHub/negotiate:1 Failed to load resource: the server responded with a status of 404 (Not Found)

Originally created by @Shimmy96 on GitHub (Aug 8, 2018). Currently working on updating my Angular6 SPA application to use real-time sockets via SignalR. Right now, when the client tries to establish a connection with the server (which is an ASP.NET Core application hosted with Electron.NET), the client fails to 'negotiate' with the server. Are there any constraints on the Electron.NET side that is blocking incoming client connections? Angular connection: ```js this._hubConnection = new signalR.HubConnectionBuilder() .withUrl(`http://localhost:1337/socket/chatHub`) .configureLogging(signalR.LogLevel.Trace) .build(); this._hubConnection.start().catch(err => console.error(err.toString())); ``` .NET Core 2.1 Server side setup for SignalR: ```cs // Configure() app.UseSignalR(routes => { routes.MapHub<ChatHub>("/socket/chatHub"); }); // ConfigureServices() services.AddCors(o => { o.AddPolicy("CorsPolicy", b => { b.AllowAnyHeader() .AllowAnyOrigin() .AllowAnyMethod() .AllowCredentials(); }); }); services.AddSignalR(); services.AddScoped<ChatHub>(); ``` Error in console: ` Debug: Starting HubConnection. Utils.js:158 Debug: Starting connection with transfer format 'Text'. Utils.js:158 Debug: Sending negotiation request: http://localhost:1337/chatHub/negotiate chatHub/negotiate:1 Failed to load resource: the server responded with a status of 404 (Not Found) `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#202