selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

Open CO0Ki3 opened this issue 3 years ago • 12 comments

What happened?

The same thing happened in the Chrome 115 version. I saw this issue and used the 117 version of the web driver and browser using Chrome Canary, but I still get session errors.

How can we reproduce the issue?

// pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>mrs-pdf</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.11.0</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-http-jdk-client</artifactId>
            <version>4.11.0</version>
        </dependency>
    </dependencies>

</project>


// java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.manager.SeleniumManager;

public class Selenium {
    public static void main(String[] args) {
        ChromeOptions co = new ChromeOptions();
        co.setBinary("/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary");
        String driverPath = SeleniumManager.getInstance().getDriverPath(co, false).driverPath;
        System.out.println(driverPath);
        System.setProperty("webdriver.http.factory", "jdk-http-client");
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://google.com");
        } finally {
            driver.quit();
        }
    }
}

Relevant log output

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'myComputer.local', ip: '--'
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.4.1', java.version: '11.0.14'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: /Applications/Google Chrome..., extensions: []}}]}]
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:232)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:159)
	at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:108)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:51)
	at Selenium.main(Selenium.java:13)
Caused by: java.io.UncheckedIOException: java.io.IOException: HTTP/1.1 header parser received no bytes
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:431)
	at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
	at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:347)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:115)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:96)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:68)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:196)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:171)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
	... 7 more
Caused by: java.io.IOException: HTTP/1.1 header parser received no bytes
	at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Utils.java:326)
	at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Http1Response.java:665)
	at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Http1AsyncReceiver.java:297)
	at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Http1AsyncReceiver.java:263)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	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:834)
Caused by: java.io.EOFException: EOF reached while reading
	at java.net.http/jdk.internal.net.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:591)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadSubscription.signalCompletion(SocketTube.java:632)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:833)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)

Process finished with exit code 1

Operating System

macOS Ventura 13.4.1

Selenium version

4.11.0

What are the browser(s) and version(s) where you see this issue?

Chrome 117.0.5935.0

What are the browser driver(s) and version(s) where you see this issue?

117.0.5935.0

Are you using Selenium Grid?

No response

CO0Ki3 avatar Aug 08 '23 10:08 CO0Ki3

@CO0Ki3, 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!

github-actions[bot] avatar Aug 08 '23 10:08 github-actions[bot]

It is the same issue, please follow the Chrome bug for updates.

diemol avatar Aug 08 '23 10:08 diemol

@diemol Has this been resolved in any version yet? Or is there a document that states a version that doesn't cause the bug?

CO0Ki3 avatar Aug 08 '23 10:08 CO0Ki3

You would need to follow up with their bug tracker. We do not have that information.

diemol avatar Aug 08 '23 11:08 diemol

@diemol thx:) I hope that the issue will be resolved quickly🔥

CO0Ki3 avatar Aug 09 '23 00:08 CO0Ki3

mee too in chrome 115

NCLnclNCL avatar Aug 21 '23 10:08 NCLnclNCL

@NCLnclNCL thx for share. I took care of it by lowering the chromium version. Try lowering the version unless you are using features that only come from the higher version.

CO0Ki3 avatar Aug 24 '23 07:08 CO0Ki3

@NCLnclNCL thx for share. I took care of it by lowering the chromium version. Try lowering the version unless you are using features that only come from the higher version.

I run with start process and connect with port

NCLnclNCL avatar Aug 24 '23 11:08 NCLnclNCL

It is probably because your Chrome version updated to the last version and chromedriver still trying to use the older one. I recommend you set the browser version by ChromeOptions:

       ChromeOptions options = new ChromeOptions();
        options.setCapability("browserVersion", "116.0.5845.111");

Or...

 ChromeOptions options = new ChromeOptions();
        options.setBrowserVersion("116.0.5845.111");``

At least, it changed the error for me. I'm trying to use a remote browser for my project with bonigarcias's library, but how you are using the chromedriver setting the driver's path will probably work.

To conclude, you may check the latest chromedriver versions.

I wish you good luck!

Calazhen avatar Aug 24 '23 14:08 Calazhen

I am not understanding WHY there needs to be a freezing of the version when the Selenium project is so vocal about the fact that WebDriver Manager is merged with Selenium Manager and the management of drivers and browses is automatic

It does not even help when you dont have ANY browser on the system and expect Selenium Manager to Download the Browser and Drivers. In a case like this, it caches the browser and driver but does NOTHING, nada with it. Either I'm missing something, or this is seriously bugged on the Selenium side AND the Chrome side.

Please advise the workaround as Chrome being updated and Selenium looking for the CFT Driver does not help.

The Docker container having maven and Java 17 on Ubuntu keeps giving the Error : Unable to obtain: Capabilities {browserName: chrome, goog:chromeOptions: {args: [--no-sandbox, --disable-dev-shm-usage, --headless, --window-size=1920,1200, disable-gpu, --remote-allow-origins=], extensions: []}}, error Command failed with code: 65, executed: [--browser, chrome, --output, json] request or response body error: error reading a body from connection: connection reset Build info: version: '4.12.0', revision: '249f2a7d1b' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.192-183.736.amzn2.x86_64', java.version: '13.0.1' Driver info: driver.version: ChromeDriver

Not sure whats happenning here

dhavewala avatar Nov 01 '23 04:11 dhavewala

https://www.selenium.dev/documentation/selenium_manager/#connectivity-issues

titusfortner avatar Nov 01 '23 09:11 titusfortner

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.

github-actions[bot] avatar Dec 02 '23 19:12 github-actions[bot]