Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server hub connection from asp.net core 2.2 signalr console app

I have a server running .net 4.5.1 with SignalR (IIS)

I want to connect to the server using a console client app on .net core 2,2. I have installed the below Nuget package on the client

Microsoft.AspNetCore.SignalR.Client;

and have followed

https://learn.microsoft.com/en-us/aspnet/core/signalr/dotnet-client?view=aspnetcore-2.2

I keep getting the below error

"There was an error opening the connection:System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found)."

The name of my Hub on the server is correct so I'm not sure of the problem

I have also tried

.WithUrl("http://172.10.0.20:81/client/?hub=myHub")

please help

connection = new HubConnectionBuilder()

//.WithUrl("http://172.10.0.20:81/client/?hub=myHub")

.WithUrl("http://172.10.0.20:81/myHub")

.Build();

connection.StartAsync().ContinueWith(task => {

if (task.IsFaulted)

{Console.WriteLine("There was an error opening the connection:{0}",

task.Exception.GetBaseException());}

else

{Console.WriteLine("Connected");}}).Wait();

connection.StartAsync();
like image 344
AShah Avatar asked Oct 17 '25 12:10

AShah


1 Answers

I can't reproduce your problem . But since your server is hosted on .net 4.5.1 , please make sure that you are using same version of SignalR both on server side and client side .

That means that you you cannot use the ASP.NET CORE SignalR (Hub or Client) with the ASP.NET SignalR (Hub or Client). You can't mix them. You can click here for more info .

like image 182
Nan Yu Avatar answered Oct 19 '25 00:10

Nan Yu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!