使用长轮询时/ signalr / ping呼叫使用 [英] Use of /signalr/ping call when using long polling

查看:899
本文介绍了使用长轮询时/ signalr / ping呼叫使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是长轮询SignalR。我发现,用户会话结束基于singalr网页制作(ASP.NET Session_End中被调用)之后的 / signar /平的请求(的在这个截图显示)。我通过<一去href=\"http://www.asp.net/signalr/overview/signalr-20/hubs-api/handling-connection-lifetime-events\">http://www.asp.net/signalr/overview/signalr-20/hubs-api/handling-connection-lifetime-events但无法弄清楚以下问题明确的答案。


  1. 如何从signalr客户端的网页保持ASP.net用户会话还活着吗?

  2. 什么是/平的实际目的是什么?

  3. 是时机为此/ ping呼叫配置?


解决方案

在/ signalr / ping请求的整个目的是保持ASP.NET会活着。通过比会话超时固定的间隔较短提出请求,会议应永远不会过期,因为服务器必须重新对每个请求超时。

在长轮询运输的情况下,这可能是不必要的,因为SignalR将迫使新的长轮询的至少的给出的默认配置每110秒。即便如此,SignalR将ping请求每隔5分钟默认情况下,无论是使用什么交通工具。这家5分钟间隔小到足以应付ASP.NET的缺省为20分钟的会议暂停。

您可以恒温5分钟ping时间间隔在你调用自定义的值更改为 $ connection.hub.start 像这样:

  //配置SignalR来ping服务器每分钟
$ .connection.hub.start({pingInterval:60000})// ...

默认 pingInterval 为300000毫秒(5分钟)。您可以通过 pingInterval 设置为null禁用平。

I'm using long polling with SignalR. I've found that user session ends (ASP.NET Session_End is being called) right after singalr based webpage makes /signar/ping request (as shown in this screenshot). I went through http://www.asp.net/signalr/overview/signalr-20/hubs-api/handling-connection-lifetime-events but couldn't figure out clear answers following questions.

  1. How to keep ASP.net user session alive from a signalr client webpage?
  2. What is the actual purpose of /ping?
  3. Is the timing for this /ping call configurable?

解决方案

The entire purpose of the /signalr/ping request is to keep ASP.NET sessions alive. By making requests on a regular interval shorter than the session timeout, the session should never expire since the server should reset the timeout on each request.

In the case of the long polling transport, this is probably unnecessary since SignalR will force a new long poll at least every 110 seconds given the default configuration. Even so, SignalR will make a ping request every 5 minutes by default no matter what transport is in use. This 5 minute interval is small enough to deal with ASP.NET's default 20 minute session timeout.

You can change the 5 minute ping interval to a custom value in your call to $.connection.hub.start like so:

// Configure SignalR to ping the server every minute
$.connection.hub.start({ pingInterval: 60000 })//...

The default pingInterval is 300000 milliseconds (5 minutes). You can disable the ping by setting pingInterval to null.

这篇关于使用长轮询时/ signalr / ping呼叫使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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