如果浏览器选项卡不活动,则SignalR连接超时 [英] SignalR connection timeouts if browser tab is inactive

查看:97
本文介绍了如果浏览器选项卡不活动,则SignalR连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我保持浏览器选项卡处于活动状态(每5-6分钟至少打开一次),则我的WebSocket连接会通过ping请求保持活动状态(请参阅随附的屏幕截图).但是,如果我放弃选项卡10分钟左右,则/ping请求将停止发生,并且WebSocket连接将终止.关于此的任何解释以及如何在设备处于唤醒状态时绕过它以使连接保持活动状态?

If I keep browser tab active (open it at least once per 5-6 mins) my WebSocket connection keeps alive through ping requests (see attached screenshot). But if I abandon the tab for 10 minutes or so, /ping requests stop happening and WebSocket connection terminates. Any explanation for this and how can it be bypassed to keep connection alive while device is awake?

PS:我怀疑我们最近向Azure Web服务的迁移可能是相关的.否则某些浏览器策略可能会更改.在实施SignalR几年后,我们现在第一次遇到了此类问题.

PS: I suspect that our recent migration to Azure Web services could be related. Or some browser policies could change. Having SignalR implemented for a few years we now experience such issues for the first time.

推荐答案

我们能够通过将断开超时时间增加到90s并将服务器(ASP.NET应用)上的keep alive属性设置为10s来缓解此问题.

We were able to mitigate the issue by increasing disconnect timeout to 90s and setting keep alive property to 10s on the server (ASP.NET app).

GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(90);
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);

但是我仍在等待有关Github的正式答复.

But I'm still waiting for an official response on Github.

这篇关于如果浏览器选项卡不活动,则SignalR连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆