Skip to content

Commit d097f6d

Browse files
authored
[test] Fix WebsockifyServerHarness on ipv6 enabled machine. NFC (#22822)
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. The only thing that `source_is_ipv6=True `does is set `prefer_ip6` which in turn just reveres the list of results from the DNS lookup: https://github.com/novnc/websockify/blob/417210f2cf8db9cd3cd9d86c45ef954778176b0e/websockify/websockifyserver.py#L454-L455
1 parent 5c637a6 commit d097f6d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/test_sockets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ def __enter__(self):
6565

6666
# start the websocket proxy
6767
print('running websockify on %d, forward to tcp %d' % (self.listen_port, self.target_port), file=sys.stderr)
68-
wsp = websockify.WebSocketProxy(verbose=True, listen_port=self.listen_port, target_host="127.0.0.1", target_port=self.target_port, run_once=True)
68+
# source_is_ipv6=True here signals to websockify that it should prefer ipv6 address when
69+
# resolving host names. This matches what the node `ws` module does and means that `localhost`
70+
# resolves to `::1` on IPv6 systems.
71+
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)
6972
self.websockify = multiprocessing.Process(target=wsp.start_server)
7073
self.websockify.start()
7174
self.processes.append(self.websockify)

0 commit comments

Comments
 (0)