Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium unreachable browser exception, java socket exception

Recently, especially with multiple tasks and processes running on the same pc, selenium webdriver 2 is giving many unreachable browser exceptions which are always with a java socket exception:

 Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException:                         Could not start a new session. Possible causes are invalid address of the remote server or     browser start-up failure.
   Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
  System info: os.name: 'Windows Vista', os.arch: 'x86', os.version: '6.0',       java.version: '1.7.0_05'
   Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:493)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:185)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:178)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:174)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:92)

    Caused by: java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:150)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:575)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:297)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:136)
at org.openqa.selenium.firefox.FirefoxDriver$LazyCommandExecutor.execute(FirefoxDriver.java:357)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
... 7 more

Why does this happen so often? Is selenim 2.25 incompatible with firefox 14?

like image 781
Michael Roller Avatar asked Oct 06 '22 21:10

Michael Roller


2 Answers

I found myself struggling with this issue for months, i really tried almost everything but still got random "UnreachableBrowserException" errors.

This is the only working solution for me.

System.setProperty("java.net.preferIPv4Stack" , "true");
like image 161
zvikachu Avatar answered Oct 23 '22 12:10

zvikachu


I also had the same issue with Selenium Web Driver. Specially when I run a long test scripts without restarting the web driver. Then I moved to a new machine with much performance and then I could avoid it nearly 90 %.

I assumed this happened because of lack of memory and I upgraded my RAM up to 4GB in my new machine.

That solved my issue and now everything is OK.

Note : Please check whether you close the driver correctly after every test run.It also may lead to kill the driver due to memory leak.

like image 1
kushan Avatar answered Oct 23 '22 12:10

kushan