Skip to content

SignalR unable to connect client to server #159

@Shimmy96

Description

@Shimmy96

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions