Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 833
Maros Avatar asked Apr 03 '14 04:04

Maros


1 Answers

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.

like image 95
Maros Avatar answered Oct 19 '22 08:10

Maros