.net – SignalR长轮询在5秒内断开连接
|
我的应用程序在公司网络下工作(丑陋的代理和东西).它不能很好地工作.我希望使用https会有所帮助,但事实并非如此.这是我在日志中看到的奇怪模式: [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Client subscribed to hub 'modemshub'. [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionToken=6aktO0sramoQKhQ9DC7Cs7EbXMUou8LooQRxfup4R0oZCHpBmWBFjyLup%2F3wJLloR8GtJEiUk10YOZJBaSqN8aiGAfXRR4G9hujTFTyiJiz%2FyJ4oMlBIdxqeCc5anI6k&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'. [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: longPolling transport starting. [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Opening long polling request to 'https://example.com/signalr/connect?transport=longPolling&clientProt…rlCzGHl5kVLClT5ex8&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'. [14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: Long poll complete. [14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: LongPolling connected. [14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: longPolling transport connected. Initiating start request. [14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: Opening long polling request to 'https://example.com/signalr/poll?transport=longPolling&clientProtoco…rlCzGHl5kVLClT5ex8&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'. [14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state. [14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Long poll complete. [14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Stopping connection. [14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Fired ajax abort async = true. 因此连接建立,5秒后中止(ConnectionTimeout等于110秒).并且这种模式一再重复.那太奇怪了. 解决方法背景根据Asp.net:
Troubleshooting请注意,SignalR 2.1引入了保持活动以进行长轮询.如果某些事情干扰了分块的HTTP响应,这可能会有问题.如果要禁用keepalive功能,请将KeepAlive设置为null.长轮询传输会自动禁用Keepalive功能. 如果您是using a Self-Host,请使用以下3 args: GlobalHost.Configuration.ConnectionTimeout = new TimeSpan(0,110); GlobalHost.Configuration.DisconnectTimeout = new TimeSpan(0,30); GlobalHost.Configuration.KeepAlive = new TimeSpan(0,10); 作为支持长时间轮询的保持“喜欢”功能的不同替代方法,请创建服务器方法名称Ping: public class MyHub : Hub
{
public void Ping()
{
}
}
然后,在客户端上创建一个用于Ping服务器的时间间隔: var proxy = $.connection.myHub,intervalHandle;
...
$.connection.hub.disconnected(function() {
clearInterval(intervalHandle);
});
...
$.connection.hub.start().done(function() {
// Only when long polling
if($.connection.hub.transport.name === "longPolling") {
// Ping every 10s
intervalHandle = setInterval(function() {
// Ensure we're connected (don't want to be pinging in any other state).
if($.connection.hub.state === $.signalR.connectionState.connected) {
proxy.server.ping().fail(function() {
// Failed to ping the server,we could either try one more time to ensure we can't reach the server
// or we could fail right here.
TryAndRestartConnection(); // Your method
});
}
},10000);
}
});
我希望有用. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 如何从HttpResponseMessage获取对象?
- asp.net-mvc-3 – asp.net mvc3请求线程亲和
- 如何删除IIS自定义标头像X-Powered-By:ASP.NET从响应?
- ASP.NET MVC项目“不支持此安装”
- asp.net-mvc-3 – 验证摘要消息中的链接
- .net – 单个配置密钥的多个值
- asp.net – HTTP错误403 – 禁止
- ASP.NET MVC Web应用程序中视图逻辑和域逻辑之间的混淆
- asp.net – 如何使用HtmlEncode与TemplateFields,数据绑定和
- asp.net – MapRoute和MapPageRoute有什么区别?
- asp.net-mvc – MVC 5防止通过iframe访问内容
- asp.net – 为什么即使我将EnableViewState设置为
- asp.net-mvc – ASP.NET MVC – HttpException或
- 最好的TinyMce编辑器图像管理器/文件上传为Asp.n
- asp.net – Visual Studio 2008使用CodeBehind失
- asp.net – 如何在隐藏字段(TextBox)上触发Requi
- asp.net-mvc – 在不显眼的验证过程中使用parseJ
- asp-classic – Response.Write和%=%
- asp.net-mvc – 什么是ASP.Net MVC查看引擎?
- 使用ASP.NET MVC和JQuery表单插件/文件上传检测I
