【问题标题】:connect signalr server from dotnet4 console app从 dotnet4 控制台应用程序连接信号器服务器
【发布时间】:2018-04-20 02:35:04
【问题描述】:

我有一个在 AspNetCore 2.1.0-preview2-final 上运行的 signalR 服务器,地址为 https://localhost:44384/chathub。我的 Web 客户端和 dotnetcore 控制台应用程序成功连接到服务器,但 dotnet4 控制台应用程序失败。

SignalR 服务器 Startup.cs\Configure:

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

在同一 signalR 服务器中运行的 Web 客户端:成功

const connection = new signalR.HubConnection(
"/chathub",
{
    logger: signalR.LogLevel.Information
});

dotnetcore 控制台应用程序(Microsoft.AspNetCore.SignalR.Client 1.0.0-preview2-final):成功

_connection = new HubConnectionBuilder()
             .WithUrl("https://localhost:44384/chathub")
             .WithConsoleLogger()
             .Build();

dotnet4 控制台应用程序(Microsoft.AspNet.SignalR.Client 2.2.3.0):失败

hubConnection = new HubConnection("https://localhost:44384/chathub");

            hubProxy = hubConnection.CreateHubProxy("ChatHub");

            await hubConnection.Start();

例外是:

StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent,...

有什么想法吗?

【问题讨论】:

    标签: asp.net-core signalr


    【解决方案1】:

    SignalR 2.2.3 与 SignalR for ASP.NET Core 不兼容。您不能将旧客户端与新服务器或旧服务器与新客户端一起使用。

    【讨论】:

    • 非常感谢。只需从 nuget 安装 System.Numerics.Vectors (4.5.0-preview2-26406-04) 和 Microsoft.AspNetCore.SignalR.Client (1.0.0-preview2-final)
    • 我认为客户端包应该拉取你需要的所有依赖。
    猜你喜欢
    • 1970-01-01
    • 2019-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-10
    • 1970-01-01
    • 2022-11-15
    • 1970-01-01
    相关资源
    最近更新 更多