【问题标题】:Unable to reconnect SignalR JS client after recycle of application pool应用程序池回收后无法重新连接 SignalR JS 客户端
【发布时间】:2013-04-11 20:49:00
【问题描述】:

当我为运行 SignalR 集线器的站点回收应用程序池时,javascript 客户端无法重新连接。但是,如果客户端在他的浏览器上进行刷新,一切都会好起来的。

在客户端控制台日志中,这些行在应用程序池重置后每秒重复多次:(我已将连接令牌替换为 abcd)

LOGG: [15:51:19 UTC+0200] SignalR: Raising the reconnect event  
LOGG: [15:51:19 UTC+0200] SignalR: An error occurred using longPolling. Status = parsererror. undefined  
LOGG: [15:51:19 UTC+0200] SignalR: SignalR: Initializing long polling connection with server.  
LOGG: [15:51:19 UTC+0200] SignalR: Attempting to connect to 'http://lab/signalr/reconnect?transport=longPolling&connectionToken=abcd' using longPolling. 
LOGG: [15:51:19 UTC+0200] SignalR: Raising the reconnect event 

我已尝试禁用集线器上的所有身份验证,但结果仍然相同。 服务器和客户端都在 SignalR v1.0.1 上运行

客户端的hubconnection是这样设置的:

var connection = $.hubConnection('http://lab:8097', { logging: true });
var proxy = connection.createHubProxy('task');
connection.start({ jsonp: true }).done(function () {
    proxy.invoke('OpenTask', id);
});

我也在服务器端集线器注册上使用跨域:

RouteTable.Routes.MapHubs(new HubConfiguration { EnableCrossDomain = true });

服务器运行在IIS 7.5上,客户端是IE9。

有人知道怎么了?

【问题讨论】:

    标签: asp.net-web-api signalr signalr-hub


    【解决方案1】:

    此问题将在 1.1 RTW 中解决(尚未发布,目前只有测试版)。

    修复方法如下:https://github.com/SignalR/SignalR/issues/1809,供您参考。如果您想更早地进行修复,您可以实施问题中提到的更改。

    最后,如果您确实选择实施修复,您将需要处理连接上的 .disconnected 事件并完全重新启动连接。

    【讨论】:

    • 谢谢!我实现了 1.1 RTW javascript,现在重复重新连接在 30 秒后停止,而不是无限重复!
    • 解决了吗?因为我使用 1.1.1 并遇到相同的行为——应用程序池回收后客户端没有重新连接。在这里查看我的描述:github.com/SignalR/SignalR/issues/2095
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 1970-01-01
    • 2012-09-25
    • 2017-05-26
    • 2011-08-28
    • 2016-04-29
    • 2015-12-15
    相关资源
    最近更新 更多