Closed auttam0 closed 2 years ago
Thanks for the report @auttam0 and sorry that it took a bit longer. I finally had the time to investigate and filed https://bugzilla.mozilla.org/show_bug.cgi?id=1770914.
Note that for now as workaround you want to use the --host "::1"
argument when starting geckodriver, which will bind it socket to the IPv6 address only. But as I read this should be fine for you.
@whimboo Thanks for your response. I had tried with explicitly setting the host (mentioned below) but it didn't work and above exception occured.
FirefoxOptions options = new FirefoxOptions();
options.addArguments("--host").addArguments("::1");
Strange. I can see that still 127.0.0.1
is used. I thought you have a IPv6 only stack? So how could geckodriver bind a IPv4 address to listen on? There shouldn't be such an IP available at all.
Could you check that outside of Selenium please? Would be good to have any extra layer removed.
@whimboo I tried directly invoking geckodriver explcitly mentioning host ::1
geckodriver -vv --host ::1
1653554568480 geckodriver INFO Listening on [::1]:4444
thread 'webdriver server' panicked at 'Failed to parse server hostname as a host: InvalidDomainCharacter', /builds/worker/workspace/build/src/testing/webdriver/src/server.rs:270:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
then used netcat to connect to geckodriver via IPv6:
nc -vz ::1 4444
Connection to ::1 4444 port [tcp/krb524] succeeded!
However when trying same through selenium & explicitly setting host as ::1
it still listens on 127.0.0.1
& fails to connect with trace as mentioned initially in the problem statement.
In the java class GeckoDriverService
, method createArgs()
doesn't sets host
. How can we specify host
through geckodriver java api?
That's great to hear and yes, setting the host via the Firefox options doesn't work out. If you have trouble setting the geckodriver host via Selenium please consult the appropriate Selenium binding documentation, and if no options like that is present you could file a new feature request. I'm pretty sure that they can get it added pretty easily.
Nevertheless we will try to make it easier in an IPv6 (or dual-stack) network and that work is covered on https://bugzilla.mozilla.org/show_bug.cgi?id=1770914.
Given that this bug is pointing to an issue in Selenium I'm going to close it.
System
Testcase
On an IPv6 only network stack, the geckodriver is listening on IPv4 url & during execution connection is made to IPv6 address which it fails to connect
Stacktrace
1652345898394 geckodriver INFO Listening on 127.0.0.1:25540 Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:25540 Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: '{HOST_NAME}', ip: '{IPV6_Address}', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.18-24.96-default', java.version: '1.8.0_301' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147)
... 5 more
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:25540
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
... 10 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
at java.net.Socket.connect(Socket.java:606)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
... 32 more
Trace-level log
1652345898394 geckodriver INFO Listening on 127.0.0.1:25540
No other trace logs generated.