Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium abotring with "UnreachableBrowserException/Address already in use" occurring on one computer

I have a java webdriver driven selenium execution which does a loop over a list to enter different infomation into a textbox and sending it using the FirefoxDriver.

On one computer, quite reproducible, after the 10th or 11th iteration, the call of findElement(By.id("mi4")) raises an UnreachableBrowserException.

Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: I/O exception (java.net.BindException) caught when connecting to the target host: Address already in use: connect
Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: Retrying connect
Jun 29, 2012 1:52:02 PM org.apache.http.impl.client.DefaultRequestDirector tryConnect
Information: I/O exception (java.net.BindException) caught when connecting to the target host: Address already in use: connect
...
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 15:28:49'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_04'
Driver info: driver.version: RemoteWebDriver
   at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:467)
   at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:242)
Caused by: java.net.BindException: Address already in use: connect
   at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
   at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
   at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:337)
   at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:297)
   at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.execute(NewProfileExtensionConnection.java:136)

There is no third party program listening on any ports. However, I use two instances of FirefoxDriver, meaning two Firefox instances/Windows opened in parallel, which works without any problem on a Win7 machine, the problem described occurs on a Windows XP machine.

I use Firefox 13 with selenium 2.24.1.

like image 670
stracktracer Avatar asked Jun 29 '12 12:06

stracktracer


1 Answers

It sounds like you are running out of ephemeral ports since you are iterating over and over. The default maximum number of ephemeral TCP ports is 5000 in windows XP. Try increasing the limit as per the resolution in Microsoft KB article here. Restart the machine. This solution has worked for me.

like image 100
nilesh Avatar answered Sep 28 '22 06:09

nilesh