[🐛 Bug]: Build RemoteWebDriver with ip Proxy get error
What happened?
I use selenium grid to get a chrome driver with ip proxy,get error,i watch the code from error code,It is found that there is one more hcode parameter,resulting in a NullPointerException,You can see the log below,code location is in org.openqa.selenium.Proxy 107,I would like to know how to solve this problem, thank you
How can we reproduce the issue?
private WebDriver initChrome() throws MalformedURLException {
URL hubUrl = new URL("http://127.0.0.1:4444");
DesiredCapabilities capabilities = new DesiredCapabilities(DesiredCapabilities.chrome());
capabilities.setCapability("pageLoadStrategy", "eager");
ProxyPool proxyPool = BeanUtil.getBean(ProxyPool.class);
ProxyPool.ProxyWrapper proxyWrapper = proxyPool.getProxy();
InetSocketAddress address = (InetSocketAddress) proxyWrapper.getProxy().address();
String ipProxy = address.getHostName() + ":" + address.getPort();
Proxy proxy = new Proxy();
proxy.setSslProxy(ipProxy);
capabilities.setCapability(CapabilityType.PROXY, proxy);
long start = System.currentTimeMillis();
WebDriver driver = new RemoteWebDriver(hubUrl, capabilities);
long end = System.currentTimeMillis();
log.info("get_WebDriver_cost:{}", end - start);
return driver;
}
Relevant log output
09:39:59.303 WARN [SeleniumSpanExporter$1.lambda$export$1] - Error while creating session with the driver service. Stopping driver service: null
09:39:59.304 WARN [SeleniumSpanExporter$1.lambda$export$1] - java.lang.NullPointerException
at org.openqa.selenium.Proxy.lambda$new$11(Proxy.java:107)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.openqa.selenium.Proxy.<init>(Proxy.java:105)
at org.openqa.selenium.remote.ProtocolHandshake$Result.lambda$static$0(ProtocolHandshake.java:179)
at org.openqa.selenium.remote.ProtocolHandshake$Result.<init>(ProtocolHandshake.java:194)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$successHandler$1(W3CHandshakeResponse.java:104)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$3(ProtocolHandshake.java:151)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:153)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:141)
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:67)
at org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:145)
at org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:362)
at org.openqa.selenium.grid.node.NewNodeSession.execute(NewNodeSession.java:52)
at org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:192)
at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
at org.openqa.selenium.grid.security.RequiresSecretFilter.lambda$apply$0(RequiresSecretFilter.java:64)
at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
at org.openqa.selenium.grid.node.Node.execute(Node.java:240)
at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
09:39:59.304 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "75d36aff28e74c0b776bfa618634ada9","eventTime": 1658223599226860486,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:41331","exception.message": "Error while creating session with the driver service. Stopping driver service: null","exception.stacktrace": "java.lang.NullPointerException\n\tat org.openqa.selenium.Proxy.lambda$new$11(Proxy.java:107)\n\tat java.base\u002fjava.util.LinkedHashMap.forEach(LinkedHashMap.java:684)\n\tat org.openqa.selenium.Proxy.\u003cinit>(Proxy.java:105)\n\tat org.openqa.selenium.remote.ProtocolHandshake$Result.lambda$static$0(ProtocolHandshake.java:179)\n\tat org.openqa.selenium.remote.ProtocolHandshake$Result.\u003cinit>(ProtocolHandshake.java:194)\n\tat org.openqa.selenium.remote.W3CHandshakeResponse.lambda$successHandler$1(W3CHandshakeResponse.java:104)\n\tat org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)\n\tat org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$3(ProtocolHandshake.java:151)\n\tat java.base\u002fjava.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)\n\tat java.base\u002fjava.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)\n\tat java.base\u002fjava.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)\n\tat java.base\u002fjava.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)\n\tat java.base\u002fjava.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)\n\tat java.base\u002fjava.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)\n\tat java.base\u002fjava.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)\n\tat java.base\u002fjava.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\n\tat java.base\u002fjava.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:153)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:141)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:67)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:145)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:362)\n\tat org.openqa.selenium.grid.node.NewNodeSession.execute(NewNodeSession.java:52)\n\tat org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:192)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.security.RequiresSecretFilter.lambda$apply$0(RequiresSecretFilter.java:64)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "java.lang.NullPointerException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{\"proxy\": {\"proxyAutoconfigUrl\": null,\"socksUsername\": null,\"socksPassword\": null,\"autodetect\": false,\"httpProxy\": null,\"proxyType\": \"MANUAL\",\"noProxy\": null,\"ftpProxy\": null,\"socksProxy\": null,\"hCode\": 1049605579,\"class\": \"org.openqa.selenium.Proxy\",\"sslProxy\": \"175.175.92.196:4261\"},\"se:noVncPort\": 7900,\"browserName\": \"chrome\",\"pageLoadStrategy\": \"eager\",\"platformName\": \"ANY\",\"version\": \"\",\"platform\": \"ANY\",\"se:vncEnabled\": true}\n"}}
Operating System
docker
Selenium version
4.4.2
What are the browser(s) and version(s) where you see this issue?
selenium/node-chrome:4.2.2
What are the browser driver(s) and version(s) where you see this issue?
selenium/node-chrome:4.2.2
Are you using Selenium Grid?
yes
@wew25, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
Does this work when you don't use Docker? Can you update your client code to 4.3.0 please?
Does this work when you don't use Docker? Can you update your client code to 4.3.0 please?
Does this work when you don't use Docker? Can you update your client code to 4.3.0 please?
update client code to 4.3.0 is useless,i find When the client processes request parameters use JsonHttpCommandCodec 228 line of code then extra this hcode parameter,It seems to be the hashcode of this,This seems to be a client issue,and the server did not deal with
Does this work when you don't use Docker? Can you update your client code to 4.3.0 please?
i find the Solution According to the client's code,use map pass parameters,don't use the proxy object,then success,Thank you for your reply
Map<String, String> proxy = new HashMap<>(); proxy.put("proxyType", "MANUAL"); proxy.put("sslProxy", ipProxy); proxy.put("httpProxy", ipProxy); capabilities.setCapability(CapabilityType.PROXY, proxy);
It's not clear at all what worked and what didn't. Does it work without Docker or what did you do to make it work?
It's not clear at all what worked and what didn't. Does it work without Docker or what did you do to make it work? work with docker,if i use selenium built-in proxy object,The above error log appears,i use a map,success,Below is the correct code; URL hubUrl = new URL("http://127.0.0.1:4444"); DesiredCapabilities capabilities = new DesiredCapabilities(DesiredCapabilities.chrome()); capabilities.setCapability("pageLoadStrategy", "eager"); String ipProxy = ""; // 代理地址 Map<String, String> proxy = new HashMap<>(); proxy.put("proxyType", "MANUAL"); proxy.put("sslProxy", ipProxy); capabilities.setCapability(CapabilityType.PROXY, proxy); WebDriver driver = new RemoteWebDriver(hubUrl, capabilities);
@wew25 can you share the code that is not working when using Selenium 4.3.0?
@diemol I played a little with the issue, but failed to reproduce the problem. I suggest to close the issue until we get a code snipper for reproducing the problem.
Makes sense. Closing for now.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.