Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Lower per-process websocket connection limits to match other browser …
…behavior https://bugs.webkit.org/show_bug.cgi?id=247100 <rdar://90340929> Reviewed by Chris Dumez. Chrome and Firefox place an upper bound on the number of connections that a single web page may have open at the same time. We should follow this behavior to avoid a poorly written web page impacting system performance. We will use Chrome's larger limit to reduce the likelihood of web compatibility issues. Tested by a new test: http/tests/websocket/tests/hybi/multiple-connections-limit.html * LayoutTests/http/tests/websocket/tests/hybi/multiple-connections-limit-expected.txt: Added. * LayoutTests/http/tests/websocket/tests/hybi/multiple-connections-limit.html: Added. * Source/WebKit/WebProcess/Network/WebSocketChannel.cpp: (WebKit::WebSocketChannel::connect): Check open connections and fail the connection attempt if we exceed them. * Source/WebKit/WebProcess/Network/WebSocketChannelManager.h: (WebKit::WebSocketChannelManager::hasReachedSocketLimit const): Added. Canonical link: https://commits.webkit.org/258488@main
- Loading branch information
1 parent
9e2245f
commit 80f4f4e
Showing
7 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/tests/websocket/tests/hybi/multiple-connections-limit-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Test that WebSocket is not subject to HTTP connection limit, but does not exceed a maximum. It should not contain any alerts about unexpected close events, and should say PASS below: | ||
|
||
PASS |
66 changes: 66 additions & 0 deletions
66
LayoutTests/http/tests/websocket/tests/hybi/multiple-connections-limit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] --> | ||
<html> | ||
<body> | ||
<p>Test that WebSocket is not subject to HTTP connection limit, but does not exceed a maximum. It should not contain any alerts about unexpected close events, and should say PASS below:</p> | ||
<p id=result>Running...</p> | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
testRunner.setAllowsAnySSLCertificate(true); | ||
} | ||
|
||
let maxSocketCount = 200; | ||
let totalAttemptedCount = 201; | ||
|
||
var result = document.getElementById("result"); | ||
var sockets = []; | ||
|
||
function openSocket() { | ||
var num = parseInt(result.innerHTML); | ||
if (!num) | ||
num = 1; | ||
if (num != maxSocketCount - 1) | ||
result.innerHTML = num + 1; | ||
else { | ||
result.innerHTML = "PASS"; | ||
|
||
for (j = 0; j < sockets.length; ++j) { | ||
sockets[j].onclose = null; | ||
sockets[j].close(); | ||
} | ||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
} | ||
} | ||
|
||
let firstHalf = Math.round(totalAttemptedCount / 2); | ||
|
||
// Our Python socket test server only allows 256 total open files (including sockets), and some | ||
// are used for log files, etc. So we can't test a 256-socket limit with a single process. | ||
// Therefore, split the test so that half go to the WS socket server, and half to the WSS server. | ||
for (i = 0; i < firstHalf; ++i) { | ||
var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/echo"); | ||
sockets[i] = ws; | ||
ws.onopen = openSocket; | ||
ws.onclose = function() { | ||
var constructionTimeI = i; | ||
if (constructionTimeI < maxSocketCount) | ||
alert("FAIL: unexpected close event") | ||
} | ||
} | ||
|
||
for (i = firstHalf; i < totalAttemptedCount; ++i) { | ||
var ws = new WebSocket("wss://127.0.0.1:9323/websocket/tests/hybi/simple"); | ||
sockets[i] = ws; | ||
ws.onopen = openSocket; | ||
ws.onclose = function() { | ||
var constructionTimeI = i; | ||
if (constructionTimeI < maxSocketCount) | ||
alert("FAIL: unexpected close event") | ||
} | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters