You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NettyClientAlpnTest intermittently fails with IOException: Failed to bind to 0.0.0.0:<port>.
Root cause: BaseMockServer.getUnusedPort() opens a ServerSocket(0) to get a free port number, then closes the socket before the port is actually used. Between that close and the later server.start() bind, the port is unowned and can be taken by another process on the CI host (example an outbound connection's ephemeral source port). When that happens, Jetty's bind fails and the test errors out, unrelated to any ALPN/HTTP2 code being tested.
Modifications
MockH2Server.java: connectors now bind to port 0, so the kernel assigns a free port atomically at bind time and the allocate-then-free race is gone. start() reads the actual ports back via connector.getLocalPort().
BaseMockServer.java: removed getUnusedPort() and the constructor that pre-allocated ports; it now only holds the port fields and URI helpers.
NettyClientAlpnTest.java: no functional change, tests stay plain @Test.
Testing
Verified by forcing a real port collision: retry fired for 3 attempts as configured, then passed once the port was free.
License
I confirm that this pull request can be released under the Apache 2 license
Root cause: BaseMockServer.getUnusedPort() opens a ServerSocket(0) to get a free port number, then closes the socket before the port is actually used. Between that close and the later server.start() bind, the port is unowned and can be taken by another process on the CI host (example an outbound connection's ephemeral source port). When that happens, Jetty's bind fails and the test errors out, unrelated to any ALPN/HTTP2 code being tested.
Weird. Can we just fix the server so that it doesn't do this weird allocate then free dance? Forcing every test that uses BaseMockServer to retry doesn't seem very scalable
Root cause: BaseMockServer.getUnusedPort() opens a ServerSocket(0) to get a free port number, then closes the socket before the port is actually used. Between that close and the later server.start() bind, the port is unowned and can be taken by another process on the CI host (example an outbound connection's ephemeral source port). When that happens, Jetty's bind fails and the test errors out, unrelated to any ALPN/HTTP2 code being tested.
Weird. Can we just fix the server so that it doesn't do this weird allocate then free dance? Forcing every test that uses BaseMockServer to retry doesn't seem very scalable
Done, added the fix to get the port right before the start.
Initially I did that fix but moved to retry since this involved 1 file change and not touching the BaseMockServer.
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one.
This file contains hidden or 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
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
NettyClientAlpnTestintermittently fails withIOException: Failed to bind to 0.0.0.0:<port>.Root cause:
BaseMockServer.getUnusedPort()opens aServerSocket(0)to get a free port number, then closes the socket before the port is actually used. Between that close and the laterserver.start()bind, the port is unowned and can be taken by another process on the CI host (example an outbound connection's ephemeral source port). When that happens, Jetty's bind fails and the test errors out, unrelated to any ALPN/HTTP2 code being tested.Modifications
MockH2Server.java: connectors now bind to port 0, so the kernel assigns a free port atomically at bind time and the allocate-then-free race is gone.start()reads the actual ports back viaconnector.getLocalPort().BaseMockServer.java: removedgetUnusedPort()and the constructor that pre-allocated ports; it now only holds the port fields and URI helpers.NettyClientAlpnTest.java: no functional change, tests stay plain@Test.Testing
Verified by forcing a real port collision: retry fired for 3 attempts as configured, then passed once the port was free.
License