Maros
Maros

Reputation: 1973

Node.js Selenium IPv6 Issue (SocketException Protocol family unavailable)

This error only happens when I spawn the ios-driver jar as a Node.js child.

The error is java.net.SocketException: Protocol family unavailable

selenium-test.js:

var spawn = require('child_process').spawn;

var selenium = spawn('java', ['-jar', './ios-server-standalone-0.6.6-SNAPSHOT.jar', '-port', '4444']);
selenium.stderr.setEncoding('utf8');
selenium.stderr.on('data', function (data){
  console.log(data);
});

webdriverjs-test.js (webdriverjs)

var webdriverjs = require('webdriverjs');
var options = {
    desiredCapabilities: {
        browserName: 'safari',
        platform: 'OS X 10.9',
        version: '7.1',
        device: 'iphone'
    }
};

webdriverjs
  .remote(options)
  .init()
  .end();

Reproduce this error by creating the above files, running selenium-test.js in one window and webdriverjs-test.js in another window. You will first need to npm install webdriverjs and curl -O http://ios-driver-ci.ebaystratus.com/userContent/ios-server-standalone-0.6.6-SNAPSHOT.jar

Version info:

$ java version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

$ node -v
v0.10.26

Why does this error happen and how do I fix it?

Upvotes: 12

Views: 1101

Answers (2)

Maros
Maros

Reputation: 1973

I managed to solve this by making the spawned child ignore stdin:

var selenium = spawn('java', ['-jar', './ios-server-standalone-0.6.6-SNAPSHOT.jar', '-port', '4444'], {stdio: ['ignore', null, null]});

I'm not sure why this workaround works.

Upvotes: 5

simpleProgrammer
simpleProgrammer

Reputation: 107

I don't have much idea about it, what so far I've found is that this can be binding issue with java. More details is on following link:(It is not the updated information, it may lead to answer)

http://diario.beerensalat.info/2008/10/12/java_and_ipv6_on_bsd.html

If that is not the case, as this post suggests to change it to higher port should work. "Protocol family unavailable" error while using VisualVM

Upvotes: 2

Related Questions