来自 asp.net 核心 2.2 信号器控制台应用程序的服务器集线器连接

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

我有一个服务器 运行 .net 4.5.1 和 SignalR (IIS)

我想在 .net core 2,2 上使用控制台客户端应用程序连接到服务器。我已经在客户端安装了下面的 Nuget 包

Microsoft.AspNetCore.SignalR.Client;

并已关注

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

我不断收到以下错误

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

服务器上我的集线器名称是正确的,所以我不确定问题所在

我也试过了

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

请帮忙

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();

我无法重现您的问题。但是由于您的服务器托管在 .net 4.5.1 上,请确保您在服务器端和客户端使用相同版本的 SignalR。

这意味着您不能将 ASP.NET CORE SignalR(集线器或客户端)与 ASP.NET SignalR(集线器或客户端)一起使用。你不能把它们混在一起。您可以点击 了解更多信息。

谢谢你把我推向了正确的方向。
我将 signalR 与 webforms 一起使用,因此集线器位于

http://172.10.0.20:82/signalr/myHub

更改路径后,我收到以下信息性错误

There was an error opening the connection:System.IO.InvalidDataException: Invalid negotiation response received. ---> System.InvalidOperationException: Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server.