Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
ANSHUL786 opened this issue Mar 28, 2024 · 25 comments

Comments

@ANSHUL786
Copy link

Do I have the most recent component updates?

  • I use the most recent available driver/plugin and server versions

Is the component officially supported by the Appium team?

  • I have verified the component repository is present under the Appium organization in GitHub

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

when i am trying to run my appium code
getting below error

FAILED CONFIGURATION: @BeforeClass UAApp.BaseComponent.AndroidBaseTest.configureAppium
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

Yesterday it is working fine.

Expected Behavior

it should start execution.

Minimal Reproducible Example

@test
public void startTest(){
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "oneplus7");
caps.setCapability("platformVersion", "12");
caps.setCapability("ignoreHiddenApiPolicyError" , true);
caps.setCapability("app", System.getProperty("user.dir") + "/src/test/java/resources/UA_QA_APP.apk");
caps.setCapability("automationName", "UiAutomator2");
driver = new AndroidDriver(new URI("http://127.0.0.1:4723").toURL(), caps);
}

Environment

  • Operating system: Windows 11
  • Appium server version (output of appium --version):2.5.1
  • Appium driver(s) and their version(s):
  • Appium plugin(s) and their version(s):
  • Node.js version (output of node --version):
  • npm version (output of npm --version):
  • Last component(s) version which did not exhibit the problem:
  • Platform and version under test:
  • Real device or emulator/simulator:

Link to Appium Logs

No response

Further Information

No response

@ANSHUL786 ANSHUL786 added the bug label Mar 28, 2024
@ANSHUL786 ANSHUL786 changed the title org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. bug: <title> org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure Mar 28, 2024
@KazuCocoa
Copy link
Member

Please attach the full appium server log

@KazuCocoa KazuCocoa removed the bug label Mar 28, 2024
@mykola-mokhnach mykola-mokhnach transferred this issue from appium/appium Mar 28, 2024
@ANSHUL786
Copy link
Author

ANSHUL786 commented Mar 28, 2024

Today i am not able to start the server via my code

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: 's-ASUS-A23', ip: '192.168.1.6'
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:268)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:161)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:90)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:102)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:109)

@simonberner
Copy link

Hi @ANSHUL786
I just had the same issue on my side and solved it by updating the appium java-client from v9.2.0 to v9.2.1. 🙂

@sanjaneya-chwy
Copy link

@simonberner -- The latest version of java client is 9.2.0...where did you get 9.2.1 from?

@sanjaneya-chwy
Copy link

I am seeing the exact same issue as well. Updated Appium to 2.5.1 and also updated Java client to 9.2.0. Any help in fixing this issue is greatly appreciated

@sanjaneya-chwy
Copy link

UPDATE: appium java-client from v9.2.0 to v9.2.1 did the trick. But I am still puzzled about how do we know to use 9.2.1 when maven website only shows 9.2.0 as latest: https://mvnrepository.com/artifact/io.appium/java-client

@valfirst
Copy link
Collaborator

@Jiyvn
Copy link

Jiyvn commented Mar 29, 2024

hit the same error with 9.2.0 using selenium 4.19. After explicitly specifying the selenium version to 4.18.1, this issue get fixed. Maybe selenium 4.19 changes causing the problem? https://github.com/SeleniumHQ/selenium/blob/acd9d0e77dc5a5a39c3a95a5aa0e94a6c4161fe7/java/CHANGELOG#L1 @KazuCocoa

@valfirst
Copy link
Collaborator

@Jiyvn https://github.com/appium/java-client?tab=readme-ov-file#compatibility-matrix

@simonberner
Copy link

@simonberner -- The latest version of java client is 9.2.0...where did you get 9.2.1 from?

@sanjaneya-chwy see https://github.com/appium/java-client/releases

@JialiLyv
Copy link

JialiLyv commented Apr 17, 2024

I am still having this issue using java-client 9.2.2 and selenium-java 4.19.0.

And I am sure my Appium Server is working as I can connect to it using Appium Inspector using the same capabilities.

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Build info: version: '4.19.1', revision: 'abe0ee07dc'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '14.4.1', java.version: '18.0.2'
Driver info: io.appium.java_client.android.AndroidDriver

@JialiLyv
Copy link

an update on this, it turned out the cache was the culprit. after changing to the above combination and reloading the mavin project fixed the issue.

@NehallBaig
Copy link

@ANSHUL786 Please use mentioned below dependencies. I hope your error will be resolved.

io.appium java-client 9.2.2 org.seleniumhq.selenium selenium-remote-driver 4.13.0 org.seleniumhq.selenium selenium-support 4.12.0

@rs-rajashrichaudhari
Copy link

rs-rajashrichaudhari commented Jan 22, 2025

I’m encountering the same issue with Selenium version 4.25.0 and Java-Client version 9.2.1. Any assistance would be greatly appreciated:
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

  1. System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.13'

  2. Driver info: io.appium.java_client.android.AndroidDriver
    lt:options={w3c=true, appiumVersion=2.15.0, isRealMobile=true, Device details - Galaxy S22 Ultra 5G, Android, 13, visual=true, autoGrantPermissions=true, platformName=Android, printPageSourceOnFindFailure=true}

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:268)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:161)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:90)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:102)
at io.appium.java_client.android.AndroidDriver.

@rajeevdaa
Copy link

Really helpful answer by downgrade java-client version issue RESOVED

@vnuta9
Copy link

vnuta9 commented Feb 28, 2025

@KazuCocoa @valfirst @simonberner @mykola-mokhnach
I hit the same/similar Exception with issue. My work space details are ...

Environment

  • Operating system: Mac Sequoia 15.3.1
  • Appium server version:2.15.0
  • Appium driver(s) and their version(s): xcuitest@7.35.1
  • Appium plugin(s) and their version(s): No plugins activated
  • Node.js version: v20.16.0
  • npm version: 10.8.1
  • Platform and version under test: iOS 18.3.1
  • Real device: Apple iPhone 11
  • JDK: 11.0.26
  • appium-java-client: 9.4.0
  • selenium-java client: 4.28.0
  • TestNG: 7.11.0

Exception Stack trace:

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: 'macmini.lan', ip: '192.168.86.21'
Build info: version: '4.29.0', revision: '5fc1ec94cb'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '15.3.1', java.version: '21.0.4'
Driver info: io.appium.java_client.ios.IOSDriver
Command: [null, newSession {capabilities=[Capabilities {appium:autoAcceptAlerts: true, appium:autoWebview: true, appium:automationName: XCUITest, appium:deviceName: Venkata Nutalapati's iPhone, appium:includeSafariInWebviews: true, appium:platformVersion: 18.3.1, appium:udid: 00008030-000159EA0E60402E, appium:webviewConnectTimeout: 50000, browserName: Safari, platformName: IOS}]}]
Capabilities {appium:autoAcceptAlerts: true, appium:autoWebview: true, appium:automationName: XCUITest, appium:deviceName: Venkata Nutalapati's iPhone, appium:includeSafariInWebviews: true, appium:platformVersion: 18.3.1, appium:udid: 00008030-000159EA0E60402E, appium:webviewConnectTimeout: 50000, browserName: Safari, platformName: IOS}
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:563)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:313)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:113)
	at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:101)
Caused by: java.io.UncheckedIOException: java.net.ConnectException
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:497)
Caused by: java.net.ConnectException
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:951)
	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:133)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:456)
Caused by: java.net.ConnectException
	at java.net.http/jdk.internal.net.http.common.Utils.toConnectException(Utils.java:1028)
	at java.net.http/jdk.internal.net.http.PlainHttpConnection.connectAsync(PlainHttpConnection.java:227)
	at java.net.http/jdk.internal.net.http.PlainHttpConnection.checkRetryConnect(PlainHttpConnection.java:280)
Caused by: java.nio.channels.ClosedChannelException
	at java.base/sun.nio.ch.SocketChannelImpl.ensureOpen(SocketChannelImpl.java:202)
	at java.base/sun.nio.ch.SocketChannelImpl.beginConnect(SocketChannelImpl.java:786)
	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:874)

Appreciate your response which can help !

@KazuCocoa
Copy link
Member

We couldn't say anything without the appium server log, but possibly it is HTTP connection related? (based on the error message the above)

@vnuta9
Copy link

vnuta9 commented Feb 28, 2025

@KazuCocoa
Thanks for the reply.
It has not hit the Appium server yet, and in the stage of creating AppiumDriver itself, we are facing this issue, . No change of log on the terminal where Appium was started and running. I usually collect and copy this terminal output as Appium logs. Other than this, I am unaware of any other(prescribed) way to collect Appium logs, sorry !
Please let me know !

@KazuCocoa
Copy link
Member

Would network debug logs such as -Djavax.net.debug=all help?

@vnuta9
Copy link

vnuta9 commented Feb 28, 2025

@KazuCocoa
Thanks for kind help !

I ran this export MAVEN_OPTS=-Djavax.net.debug=all in my Mac terminal and used eclipse to ran the test and collected the logs from eclipse console. Could be I am using it wrongly, but below is the logs attached.

Image

logs_2144.txt

@vnuta9
Copy link

vnuta9 commented Mar 1, 2025

@KazuCocoa
A small UPDATE:
After changing appium java client 9.4 and Selenium java client to 4.28.0(possibly the cause, may be...), I am getting a slightly different exception while creating the Appium Driver both for Android and iOS platforms: which is ...

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 400. Message: No such context found. 
Host info: host: 'macmini.lan', ip: '192.168.86.21'
Build info: version: '4.29.0', revision: '5fc1ec94cb'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '15.3.1', java.version: '11.0.26'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[Capabilities {appium:autoGrantPermissions: true, appium:autoWebview: true, appium:automationName: UiAutomator2, appium:deviceName: Galaxy S21 FE 5G, appium:fastReset: true, appium:platformVersion: 14, appium:udid: R5CW71PYTHE, appium:webviewConnectTimeout: 50000, browserName: Chrome, platformName: ANDROID}]}]
Capabilities {appium:autoGrantPermissions: true, appium:autoWebview: true, appium:automationName: UiAutomator2, appium:deviceName: Galaxy S21 FE 5G, appium:fastReset: true, appium:platformVersion: 14, appium:udid: R5CW71PYTHE, appium:webviewConnectTimeout: 50000, browserName: Chrome, platformName: ANDROID}
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:114)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:178)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:243)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:313)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:113)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:109)
	at com.zq.mobile.browser.test.util.SeleniumUtil.getDriver4MobileWeb(SeleniumUtil.java:211)
	at com.zq.mobile.browser.test.util.SeleniumUtil.setUp(SeleniumUtil.java:147)
	at com.zq.mobile.browser.agent.StockQuoteCreation.setUp(StockQuoteCreation.java:30)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:141)
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:71)
	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:400)
	at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:333)
	at org.testng.internal.invokers.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:188)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.testng.TestRunner.privateRun(TestRunner.java:739)
	at org.testng.TestRunner.run(TestRunner.java:614)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:421)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:413)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:373)
	at org.testng.SuiteRunner.run(SuiteRunner.java:312)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1274)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1208)
	at org.testng.TestNG.runSuites(TestNG.java:1112)
	at org.testng.TestNG.run(TestNG.java:1079)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:308)
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:71)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:113)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)

@KazuCocoa
Copy link
Member

Please attach the full appium server log as well. It looks like it is not suitable for this GitHub issue as a different topic.
https://discuss.appium.io/ would also help to get help from community.

@vnuta9
Copy link

vnuta9 commented Mar 1, 2025

@KazuCocoa
Thanks for taking time to look in to this issue posted.
Here is the log file.

appiumlogs.txt

@vnuta9
Copy link

vnuta9 commented Mar 2, 2025

@KazuCocoa
The issue got resolved by commenting WEB_VIEW capability setting...

	//setting WebView is giving exception
	//iOsOptions.setCapability("appium:autoWebview", false);// automatically shift to web view

This is the effective for both Android, and iOS both. This code used to work since more than 6 months to retrieve AppiumDriver instance. This must have been newly enforced in the latest Appium, Selenium Java client software components. In case, what I am thinking is right, what is the use of AUTOWEBVIEW ??

@KazuCocoa
Copy link
Member

The shared appium server log didn't have appium:autoWebview. Do you mean when you set appium:autoWebview as false, the issue occurred? And when you commented out the "appium:autoWebview": false, it worked...?

The given log had only ["NATIVE_APP","CHROMIUM"] contexts. As the README in https://github.com/appium/appium-uiautomator2-driver, "appium:autoWebview": true sets context for WEBVIEW_ + appium:appPackage, but not in your attached log case since you set browserName: chrome, which was CHROMIUM, it was not webview app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests