Use of /signalr/ping call when using long polling

时间秒杀一切 提交于 2019-12-05 01:23:35

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!