Skip to content

[🐛 Bug]: 401 error with new http client while creating RemoteWebDriver with URL that uses basic auth (e.g. Selenoid GGR)  #11068

@dbudim

Description

@dbudim

What 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-gridEverything grid and server relatedC-javaJava BindingsI-defectSomething is not working as intendedJ-awaiting answerQuestion asked of user; a reply moves it to triage again

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions