Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspNetCore.SignalR.Client package on Server side produces error 500 when clients connect to the Server #4683

Open
gregory-vovchok opened this issue Jul 20, 2023 · 1 comment

Comments

@gregory-vovchok
Copy link

gregory-vovchok commented Jul 20, 2023

I have ASP.NET Core Web project, target platform: .Net Core 3.1. I have SignalR Core clients that connect to my server. I want my asp.net core server to connect to another asp.net core server to get some information. But before, I need to install Microsoft.AspNetCore.SignalR.Client package to make my server to use HubConnection. When I add this package, clients can no longer connect my asp.net core web server because of error 500. I didn't find any explanation in Internet why this happens and how to fix it.

Expected behavior

Connecting to the server hub

Actual behavior

Getting server error 500 on client side when connecting to the server hub

Log:
Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync(Uri url, HttpClient httpClient, ILogger logger, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync(Uri uri, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport(TransferFormat transferFormat, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore(TransferFormat transferFormat, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync(TransferFormat transferFormat, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore(CancellationToken cancellationToken)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner(CancellationToken cancellationToken)
at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync(CancellationToken cancellationToken)
at Halloween_Night_Matchmaking_Client.MatchmakingClient.Connect(Action onComplete) in D:\MAGGOT\Studio\Halloween Night Matchmaking Client\MatchmakingClient.cs:line 81
at Halloween_Night_Matchmaking_Client_Demo.Program.InitMatchmakingClient(Action onComplete) in D:\MAGGOT\Studio\Halloween Night Matchmaking Client Demo\Program_MatchmakingClient.cs:line 90
at System.Threading.Tasks.Task.<>c.b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Steps to reproduce

  1. Create ASP.NET Core Web project, target platform: .Net Core 3.1
  2. Install Microsoft.AspNetCore.SignalR.Client package v.7.0.8 (<--- it breaks the things; removing this package fixes the problem, but I need this package to create HubConnection on server to connect another server)

The code I use on server side to create signalR:

public class Startup
    {
        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        // Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton<Matchmaking>();

            services.AddSignalR();
        }

        // Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePages();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub<MatchHub>("/matchmaking");
            });
        }
    }

The code I use to connect to the server on client side:

connection = new HubConnectionBuilder()
            .WithUrl(host)
            .Build();
@c0debeef
Copy link

This is an old SignalR 2 repo. You need ASP.NET Core SignalR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants