0

I'm using selenium to send HTTP requests to an HTTP server and I'm getting the following error after closing and reopening the connection from the test code via the same IP/port (127.0.0.1:8080). I'm pretty sure that the HTTP server application is closing the server socket on exit however I'm not so sure that the test (client) code is closing the socket.

My RemoteWebDriver implementation is below and I'm guessing that it might need to override stopClient() in order to close the socket but with what?

public class MyWebDriver extends RemoteWebDriver {

public MyWebDriver(URL url, Capabilities desiredCapabilities) {
    super(new MyCommandExecutor(url), desiredCapabilities);
}

public Response sendCommand(String command){
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("command", command);


    Response response = execute("sendCommand", parameters);

    return response;
}

}

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.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40' System info: host: '...', ip: '172.27.3.221', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.1', java.version: '1.7.0_67' Driver info: driver.version: MyWebDriver at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593) at

...

Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:8080 [/127.0.0.1] failed: Connection refused

PS: I should mention that the client code can reconnect to the server after 30 seconds or so have elapsed - the OS must be releasing the socket after that time:Java process on Mac OSX does not release socket

Community
  • 1
  • 1
Alex
  • 1
  • PS: I should mention that the client code can reconnect to the server after 30 seconds or so have elapsed - the OS must be releasing the socket after that time: http://stackoverflow.com/questions/10312488/java-process-on-mac-osx-does-not-release-socket – Alex Mar 11 '15 at 11:19
  • Probably the `RemoteWebDriver` is not releasing the port right after you disconnect it. try with a different port – Saifur Mar 11 '15 at 12:09
  • I do not think client opens any port. However you can use driver.close() and then driver.quit(). driver is instance of MyWebDriver. – Mayur Shah Mar 11 '15 at 12:21

0 Answers0