From 1bf8c8a6c26ea1d27e2b3de032230138f62b18ff Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 31 Oct 2024 14:31:18 -0700 Subject: [PATCH] [test] Fix WebsockifyServerHarness on ipv6 enabled machine. NFC The test_nodejs_sockets_echo_subprotocol_runtime test was failing on my machine because node was resolving "localhost" to the IPv6 address ::1 but the websockify server was running on the IPv4 address 127.0.0.1. --- test/test_sockets.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test_sockets.py b/test/test_sockets.py index 871a4ed92e253..f6ed86fd16841 100644 --- a/test/test_sockets.py +++ b/test/test_sockets.py @@ -65,7 +65,10 @@ def __enter__(self): # start the websocket proxy print('running websockify on %d, forward to tcp %d' % (self.listen_port, self.target_port), file=sys.stderr) - wsp = websockify.WebSocketProxy(verbose=True, listen_port=self.listen_port, target_host="127.0.0.1", target_port=self.target_port, run_once=True) + # source_is_ipv6=True here signals to websockify that it should prefer ipv6 address when + # resolving host names. This matches what the node `ws` module does and means that `localhost` + # resolves to `::1` on IPv6 systems. + wsp = websockify.WebSocketProxy(verbose=True, source_is_ipv6=True, listen_port=self.listen_port, target_host="127.0.0.1", target_port=self.target_port, run_once=True) self.websockify = multiprocessing.Process(target=wsp.start_server) self.websockify.start() self.processes.append(self.websockify)