Windows 上不同浏览器之间的 Keep-Alive 和超时行为

Windows 上不同浏览器之间的 Keep-Alive 和超时行为

简洁版本

为什么 chrome 会发送 keep-alive 而 IE 和 FF 却不会?

长版本

最初,我以为这是一个服务器端的问题。

我有一个 apache 服务器,它是 tomcat webapp 的前端代理。此应用程序上的一个页面需要 15-20 分钟才能返回结果。我发现通过 IE 或 FF 访问此页面时会超时。它会转到标准的“无法访问”页面,就像您在尝试访问网络时网线断开连接时看到的那样。然而,在 Chrome 上,它运行正常。

这让我很好奇,所以我用服务器上的 tcpdump 监视了流量,我发现了一个很大的区别。虽然 IE 和 FF 在达到超时之前一直保持沉默,但 chrome 会定期向服务器发送 ACK 数据包(并收到响应 ACK)。另外值得注意的是,IE/FF 似乎都发送了 TCP 断开连接,而不是从服务器收到任何超时。

那么,为什么 IE/FF 会断开连接而 Chrome 不会?为什么 Chrome 会发送保持连接而 IE/FF 不会?

我尝试更改 MS 推荐的注册表设置在此知识库文章中。它似乎没有改变任何行为。

来自 IE 的流量样本(FF 几乎相同)

23:25:56.814732 IP InternetExplorer.27378 > Server.https: . 83070:84430(1360) ack 154 win 65382
23:25:56.814976 IP InternetExplorer.27378 > Server.https: . 84430:85790(1360) ack 154 win 65382
23:25:56.814981 IP Server.https > InternetExplorer.27378: . ack 85790 win 63920
23:25:56.815201 IP InternetExplorer.27378 > Server.https: . 85790:87150(1360) ack 154 win 65382
23:25:56.815418 IP InternetExplorer.27378 > Server.https: . 87150:88510(1360) ack 154 win 65382
23:25:56.815422 IP Server.https > InternetExplorer.27378: . ack 88510 win 63920
23:25:56.815789 IP InternetExplorer.27378 > Server.https: . 88510:89870(1360) ack 154 win 65382
23:25:56.815916 IP InternetExplorer.27378 > Server.https: . 89870:91230(1360) ack 154 win 65382
23:25:56.815922 IP Server.https > InternetExplorer.27378: . ack 91230 win 63920
23:25:56.815929 IP InternetExplorer.27378 > Server.https: P 91230:91283(53) ack 154 win 65382
23:25:56.815940 IP Server.https > InternetExplorer.27378: . ack 91283 win 63920
23:25:56.858469 IP InternetExplorer.27378 > Server.https: . 91283:92643(1360) ack 154 win 65382
23:25:56.858773 IP InternetExplorer.27378 > Server.https: . 92643:94003(1360) ack 154 win 65382
23:25:56.858779 IP Server.https > InternetExplorer.27378: . ack 94003 win 63920
23:25:56.858992 IP InternetExplorer.27378 > Server.https: . 94003:95363(1360) ack 154 win 65382
23:25:56.859284 IP InternetExplorer.27378 > Server.https: . 95363:96723(1360) ack 154 win 65382
23:25:56.859288 IP Server.https > InternetExplorer.27378: . ack 96723 win 63920
23:25:56.859483 IP InternetExplorer.27378 > Server.https: . 96723:98083(1360) ack 154 win 65382
23:25:56.859731 IP InternetExplorer.27378 > Server.https: . 98083:99443(1360) ack 154 win 65382
23:25:56.859734 IP Server.https > InternetExplorer.27378: . ack 99443 win 63920
23:25:56.859737 IP InternetExplorer.27378 > Server.https: P 99443:99496(53) ack 154 win 65382
23:25:56.859743 IP Server.https > InternetExplorer.27378: . ack 99496 win 63920
23:25:56.902029 IP InternetExplorer.27378 > Server.https: . 99496:100856(1360) ack 154 win 65382
23:25:56.902484 IP InternetExplorer.27378 > Server.https: . 100856:102216(1360) ack 154 win 65382
23:25:56.902489 IP Server.https > InternetExplorer.27378: . ack 102216 win 63920
23:25:56.902585 IP InternetExplorer.27378 > Server.https: . 102216:103576(1360) ack 154 win 65382
23:25:56.902932 IP InternetExplorer.27378 > Server.https: . 103576:104936(1360) ack 154 win 65382
23:25:56.902935 IP Server.https > InternetExplorer.27378: . ack 104936 win 63920
23:25:56.903045 IP InternetExplorer.27378 > Server.https: P 104936:105622(686) ack 154 win 65382
23:25:56.903052 IP Server.https > InternetExplorer.27378: . ack 105622 win 63920
23:30:42.621188 IP InternetExplorer.27378 > Server.https: R 105622:105622(0) ack 154 win 9300

Chrome 的流量示例:

21:58:54.534554 IP chrome.20353 > server.https: P 10125:11337(1212) ack 146 win 65303
21:58:54.534566 IP server.https > chrome.20353: . ack 11337 win 29088
21:58:54.534621 IP chrome.20353 > server.https: P 11337:12549(1212) ack 146 win 65303
21:58:54.534625 IP server.https > chrome.20353: . ack 12549 win 31512
21:58:54.534961 IP chrome.20353 > server.https: . 12549:13761(1212) ack 146 win 65303
21:58:54.534966 IP server.https > chrome.20353: . ack 13761 win 33936
21:58:54.535082 IP chrome.20353 > server.https: P 13761:14392(631) ack 146 win 65303
21:58:54.535086 IP server.https > chrome.20353: . ack 14392 win 36360
21:59:40.021420 IP chrome.20353 > server.https: . ack 146 win 65303
21:59:40.021437 IP server.https > chrome.20353: . ack 14392 win 36360
22:00:25.147256 IP chrome.20353 > server.https: . ack 146 win 65303
22:00:25.147307 IP server.https > chrome.20353: . ack 14392 win 36360
22:01:10.244639 IP chrome.20353 > server.https: . ack 146 win 65303
22:01:10.244669 IP server.https > chrome.20353: . ack 14392 win 36360
22:01:55.410540 IP chrome.20353 > server.https: . ack 146 win 65303
22:01:55.410560 IP server.https > chrome.20353: . ack 14392 win 36360
22:02:40.568607 IP chrome.20353 > server.https: . ack 146 win 65303
22:02:40.568642 IP server.https > chrome.20353: . ack 14392 win 36360
22:03:25.720408 IP chrome.20353 > server.https: . ack 146 win 65303
22:03:25.720438 IP server.https > chrome.20353: . ack 14392 win 36360
22:04:10.861881 IP chrome.20353 > server.https: . ack 146 win 65303
22:04:10.861914 IP server.https > chrome.20353: . ack 14392 win 36360
22:04:55.977031 IP chrome.20353 > server.https: . ack 146 win 65303
22:04:55.977063 IP server.https > chrome.20353: . ack 14392 win 36360
22:05:41.085828 IP chrome.20353 > server.https: . ack 146 win 65303
22:05:41.085848 IP server.https > chrome.20353: . ack 14392 win 36360
22:06:26.251530 IP chrome.20353 > server.https: . ack 146 win 65303
22:06:26.251550 IP server.https > chrome.20353: . ack 14392 win 36360
22:07:11.416086 IP chrome.20353 > server.https: . ack 146 win 65303
22:07:11.416154 IP server.https > chrome.20353: . ack 14392 win 36360
22:07:56.554244 IP chrome.20353 > server.https: . ack 146 win 65303
22:07:56.554275 IP server.https > chrome.20353: . ack 14392 win 36360
22:08:41.713610 IP chrome.20353 > server.https: . ack 146 win 65303
22:08:41.713628 IP server.https > chrome.20353: . ack 14392 win 36360
22:09:26.874657 IP chrome.20353 > server.https: . ack 146 win 65303
22:09:26.874684 IP server.https > chrome.20353: . ack 14392 win 36360
22:10:12.033494 IP chrome.20353 > server.https: . ack 146 win 65303
22:10:12.033512 IP server.https > chrome.20353: . ack 14392 win 36360
22:10:57.266808 IP chrome.20353 > server.https: . ack 146 win 65303
22:10:57.266846 IP server.https > chrome.20353: . ack 14392 win 36360
22:11:42.453183 IP chrome.20353 > server.https: . ack 146 win 65303
22:11:42.453204 IP server.https > chrome.20353: . ack 14392 win 36360
22:12:27.599746 IP chrome.20353 > server.https: . ack 146 win 65303
22:12:27.599787 IP server.https > chrome.20353: . ack 14392 win 36360
22:13:12.762650 IP chrome.20353 > server.https: . ack 146 win 65303
22:13:12.762682 IP server.https > chrome.20353: . ack 14392 win 36360
22:13:57.923229 IP chrome.20353 > server.https: . ack 146 win 65303
22:13:57.923248 IP server.https > chrome.20353: . ack 14392 win 36360
22:14:43.077688 IP chrome.20353 > server.https: . ack 146 win 65303
22:14:43.077716 IP server.https > chrome.20353: . ack 14392 win 36360
22:15:28.252353 IP chrome.20353 > server.https: . ack 146 win 65303
22:15:28.252372 IP server.https > chrome.20353: . ack 14392 win 36360
22:16:13.424019 IP chrome.20353 > server.https: . ack 146 win 65303
22:16:13.424050 IP server.https > chrome.20353: . ack 14392 win 36360
22:16:58.564352 IP chrome.20353 > server.https: . ack 146 win 65303
22:16:58.564368 IP server.https > chrome.20353: . ack 14392 win 36360
22:17:43.725261 IP chrome.20353 > server.https: . ack 146 win 65303
22:17:43.725291 IP server.https > chrome.20353: . ack 14392 win 36360
22:17:48.597411 IP server.https > chrome.20353: . 146:2570(2424) ack 14392 win 36360
22:17:48.682782 IP chrome.20353 > server.https: . ack 2570 win 65448
22:17:48.682804 IP server.https > chrome.20353: . 2570:6206(3636) ack 14392 win 36360
22:17:48.785650 IP chrome.20353 > server.https: . ack 6206 win 65448
22:17:48.785666 IP server.https > chrome.20353: . 6206:11054(4848) ack 14392 win 36360
22:17:48.894777 IP chrome.20353 > server.https: . ack 8630 win 65448
22:17:48.894792 IP server.https > chrome.20353: . 11054:14690(3636) ack 14392 win 36360
22:17:48.905976 IP chrome.20353 > server.https: . ack 11054 win 65448
22:17:48.905990 IP server.https > chrome.20353: . 14690:17114(2424) ack 14392 win 36360
22:17:48.905996 IP server.https > chrome.20353: P 17114:17420(306) ack 14392 win 36360
22:17:48.998232 IP chrome.20353 > server.https: . ack 15902 win 65448
22:17:49.293519 IP server.https > chrome.20353: . 15902:17114(1212) ack 14392 win 36360
22:17:49.412748 IP chrome.20353 > server.https: . ack 17420 win 65448
22:17:49.921452 IP chrome.20353 > server.https: P 14392:14685(293) ack 17420 win 65448
22:17:49.921493 IP server.https > chrome.20353: . ack 14685 win 38784
22:17:49.922027 IP server.https > chrome.20353: P 17420:17862(442) ack 14685 win 38784
22:17:50.323363 IP chrome.20353 > server.https: . ack 17862 win 65006
22:18:04.921966 IP server.https > chrome.20353: P 17862:17899(37) ack 14685 win 38784
22:18:04.922078 IP server.https > chrome.20353: F 17899:17899(0) ack 14685 win 38784
22:18:05.080745 IP chrome.20353 > server.https: . ack 17900 win 64969
22:18:10.030035 IP chrome.20353 > server.https: F 14685:14685(0) ack 17900 win 64969
22:18:10.030079 IP server.https > chrome.20353: . ack 14686 win 38784

答案1

我不知道为什么,但我也观察到了同样的行为。我在这里记录了我的发现。

http://app-inf.blogspot.com/2012/09/browser-load-balancer-web-server-mod-jk.html

可能没有办法改变 IE 来发送 Keep-alive 信号,但我们更改了负载平衡器上的“Keep Alive Interval”设置来维持连接。希望这能有所帮助。

相关内容