【问题标题】:SignalR reconnect client & two different versions avaliable?SignalR 重新连接客户端和两个不同的版本可用?
【发布时间】:2018-09-12 20:35:43
【问题描述】:

我有一些关于 SignalR 的问题。

第一个问题:

我已经下载了这样的信号器:npm install @aspnet/signalr 根据Npmjs (v1.0.3)。 但是,经过进一步检查,我的信号器文件不包含重新连接功能,如在此处的github:343 上可以找到的。 事实上,这似乎是两个不同的回购。为什么不一样,好像都是微软开发的?

这是两个仓库:https://github.com/SignalR/SignalRhttps://github.com/aspnet/SignalR

第二个问题:

我尝试在我的应用程序中实现重新连接功能,但我可以使用的功能有限。这是我目前的方法(因为我在第一个 repo 中缺少重新连接功能)下面的代码会在断开连接时产生此输出:

signalr.min.js:1353 Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.

Uncaught TypeError: this.connect is not a function
at HubConnection.eval

trying to connect...
Uncaught TypeError: this.connect is not a function
at HubConnection.eval

trying to connect...
etc... etc...

代码:

this.connection.onclose(function (error) {
    if (!this.isConnected) {
        this.isConnected = false;
        appService.emit("disconnected", true);
        var intervalFunc = setInterval(function () {
            console.log("trying to connect...");
            this.connect();

            if (this.isConnected) {
                this.appService.emit("connected", true);
                this.isConnected = true;
                clearInterval(intervalFunc);
                console.log("connection established");
            }
        }.bind(this), 5000);
    }
});

在尝试实现重新连接功能时,我也遵循了这些资源:

任何帮助将不胜感激。

【问题讨论】:

    标签: asp.net angularjs typescript signalr


    【解决方案1】:

    有 .NET 版本和 .NET CORE 版本。在您链接的每个 github 的顶部显示:Incredively simple real-time web for .NET(第一个 github)和 Incredibly simple real-time web for ASP.NET Core(第二个 GitHub)。

    您的第二个问题可能归结为确定您是否混淆了每个 SignalR 产品(.NET 或 .NET CORE)和客户端。它们不是交叉兼容的,因此您不能将 .NET JS 客户端与 .NET Core 客户端一起使用。

    我会重新检查您已实施的内容并从那里开始。

    如果您查看问题下的 .NET Core 存储库并搜索重新连接,那么重新连接似乎不再是 .NET Core 中的功能。见issue 1611

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-17
      • 1970-01-01
      相关资源
      最近更新 更多