[🐛 Bug]: 401 error with new http client while creating RemoteWebDriver with URL that uses basic auth (e.g. Selenoid GGR)
See original GitHub issueWhat happened?
Received 401 error with new http client while creating RemoteWebDriver with host with basic auth (e.g. Selenoid GGR hub with quotas - http://user:pass@my.awesome.hub)
It happened if enabled jdk-http-client
https://www.selenium.dev/blog/2022/using-java11-httpclient/
Without System.setProperty("webdriver.http.factory", "jdk-http-client"); works fine
How can we reproduce the issue?
- Enable new http client https://www.selenium.dev/blog/2022/using-java11-httpclient/
- Try start RemoteWebDriver with URL with basic auth `http://user:pass@my.awesome.hub`
Relevant log output
Caused by: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Unable to parse remote response: 401 Unauthorized
Host info: host: '28504ca6c95d', ip: '172.17.0.5'
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:130)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at qa.airslate.selenium.core.browsers.hub.SelenoidBrowser.setupDriver(SelenoidBrowser.java:62)
... 27 more
Caused by: org.openqa.selenium.json.JsonException: Unable to parse: 401 Unauthorized
at org.openqa.selenium.json.Json.toType(Json.java:57)
at org.openqa.selenium.json.Json.toType(Json.java:50)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:127)
... 36 more
Caused by: org.openqa.selenium.json.JsonException: Expected to read a START_MAP but instead have: NUMBER. Last 0 characters read:
Build info: version: '4.5.0', revision: 'fe167b119a'
System info: os.name: 'Linux', os.arch: 'aarch64', os.version: '4.14.214-160.339.amzn2.aarch64', java.version: '11.0.10'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.json.JsonInput.expect(JsonInput.java:307)
at org.openqa.selenium.json.JsonInput.beginObject(JsonInput.java:229)
at org.openqa.selenium.json.MapCoercer.lambda$apply$1(MapCoercer.java:64)
at org.openqa.selenium.json.JsonTypeCoercer.lambda$buildCoercer$6(JsonTypeCoercer.java:145)
at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:127)
at org.openqa.selenium.json.Json.toType(Json.java:71)
at org.openqa.selenium.json.Json.toType(Json.java:55)
... 38 more
Operating System
linux
Selenium version
4.5.0
What are the browser(s) and version(s) where you see this issue?
104
What are the browser driver(s) and version(s) where you see this issue?
RemoteWebDriver
Are you using Selenium Grid?
no
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unexpected error. 401 Unauthorized while connecting to ...
I am using selenoid+ ggr , most of the time it worked well but suddenly I start getting OpenQA.Selenium.WebDriverException : Unexpected ...
Read more >aerokube - Bountysource
I'm trying to create a selenium cluster using ggr. It's throwing below error: org.openqa.selenium.WebDriverException: cannot create session chrome-80.0 on any ...
Read more >[🐛 Bug]: 401 error with new http client while creating ... - PullAnswer
Bug ]: 401 error with new http client while creating RemoteWebDriver with URL that uses basic auth (e.g. Selenoid GGR)
Read more >Are there common situations that cause a "401 Error" being ...
There is a GPO and Google Workspace setting that only allows basic auth using HTTPS - GPO, Chrome Policy. Do the credentials to...
Read more >Getting a 401 response using Chrome (but not Firefox)
I'm experiencing an auth error with ChromeDriver in a Rails 2.3.8 environment using REE 1.8.7, Selenium 2.0.1, Capybara 0.4.1.2, and. Cucumber-Rails 0.3.2.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you for sharing the details and providing an alternate solution. I have used the same and it was also a part of existing asynchttpclient support. I have tested the changes to fix this in the commit https://github.com/SeleniumHQ/selenium/commit/101b42d5d899de4be4995c44af953add5ee73b05 locally using the Grid’s “username” and “password” command line parameters and run the following code snippet. Before the changes, I was able to reproduce the error.
Thank you for sharing the feedback. I do not see when Grid is used without basic auth. The JDK HTTP Client works as expected. However, when I set up the Grid using basic auth and the same on the client side, I see the errors shared above. I will triage it further today.