【发布时间】:2014-01-23 21:37:55
【问题描述】:
我正在 W7 机器上使用 Chrome、.NET 4.5.1 和 IIS 7.5 开发 SignalR 2.0.1 应用程序。
该应用运行良好,但深入研究活动我发现了一些奇怪的东西。首先,它将 SSE 协商为传输:
[12:54:37 GMT+0000 (GMT Standard Time)] SignalR: Negotiating with 'updates/negotiate?user=true&clientProtocol=1.3'.
[12:54:37 GMT+0000 (GMT Standard Time)] SignalR: Attempting to connect to SSE endpoint '<url>/updates/connect?transport=serv…bLFxY6YS1OOyLL%2FtuAUH63PQEu2SFoXeYaS9X0yZQu%2BWUJ1TXM%2FG&user=true&tid=3'.
[12:54:37 GMT+0000 (GMT Standard Time)] SignalR: EventSource connected.
[12:54:37 GMT+0000 (GMT Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000.
在“网络”选项卡中,在 Chrome 开发人员工具中,我可以看到内容类型为“文本/事件流”的请求,尽管看起来已经完成,但随着时间和内容的增长。
但是,我也可以看到很多似乎是“长轮询”连接:
XHR finished loading: http://localhost:6725/738305d7ff914c0b8abf0d68490625af/arterySignalR/poll?transport=longPolling&connectionToken=<token>&requestUrl=<url>&browserName=Chrome&tid=4&_=1389012957485
我可以看到这些连接是如何开始的,并且需要很长时间才能完成。
为什么会这样?一开始我以为是“keep alive”,但是为什么keep alive要使用长轮询呢?
干杯。
【问题讨论】:
标签: asp.net signalr long-polling server-sent-events