browserstack / browserstack-local-nodejs

NodeJS bindings for BrowserStack Local
https://www.browserstack.com
MIT License
71 stars 56 forks source link

Fails when trying to use proxy- or localIdentifier-settings #12

Closed luhmann closed 8 years ago

luhmann commented 8 years ago

Steps to reproduce

Extend the example from README.md to use localIdentifier:

var browserstack = require('browserstack-local');

// creates an instance of Local
var bs_local = new browserstack.Local();

// replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
var bs_local_args = {
  'key': '<browserstack-accesskey>', // actual key here of course
  'localIdentifier': 'foo'
};

// starts the Local instance with the required arguments
bs_local.start(bs_local_args, function() {
  console.log("Started BrowserStackLocal");
  console.log(bs_local.isRunning());
});

// check if BrowserStack local instance is running
console.log(bs_local.isRunning());

// stop the Local instance
bs_local.stop(function() {
  console.log("Stopped BrowserStackLocal");
});

OS: Mac OSX 10.11.5 Node Version: Tried 4.3.2 and 6.2.2

Expected Result

Same as when only specifiying the access-key (which works)


Same thing happens when you specify proxy-settings:

var browserstack = require('browserstack-local');

// creates an instance of Local
var bs_local = new browserstack.Local();

// replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
var bs_local_args = {
  'key': '<access-key>', // actual key here of course
  'proxyHost': 'proxy.example.de', // actual proxy host here instead
  'proxyPort': '8080',
};

// starts the Local instance with the required arguments
bs_local.start(bs_local_args, function() {
  console.log("Started BrowserStackLocal");
  console.log(bs_local.isRunning());
});

// check if BrowserStack local instance is running
console.log(bs_local.isRunning());

// stop the Local instance
bs_local.stop(function() {
  console.log("Stopped BrowserStackLocal");
});

Result is same as above, but the log message now is: *** Error: Could not connect to -proxyHost proxy.example.de!

What I tried

  1. I traced the error back to the https://github.com/browserstack/browserstack-local-nodejs/blob/master/lib/Local.js#L31 and inspected that.binaryPath and that.getBinaryArgs(). When I just concatenate the binaryPath and the args-array as node should execute them (eg. /Users/foo/.browserstack/BrowserStackLocal -d start -logFile /Users/foo/browserstack-local-tryout/local.log <real access key> -proxyHost proxy.example.de -proxyPort 8080) everything works as expected.
  2. The problem seems to occur with all options that are made up out of a cli-flag that requires options such as localIdentifier, proxyHost and proxyPort. I also tried to execute childProcess.execFile like this childProcess.execFile(that.binaryPath, [ '-d', 'start', '-logFile' './browserstack-local-tryout/local.log', '<browserstack-accesskey>', '-localIdentifier', 'foo' ]) without success
vedharish commented 8 years ago

This was resolved in this commit (released in v1.0.0)

@luhmann Please re-open if you still face the issue