browserstack / browserstack-local-nodejs

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

How to test localhost:8000? #17

Closed xcambar closed 8 years ago

xcambar commented 8 years ago

Hi, I'm getting trouble using BrowserStack Local to tunnel localhpst:8000 to Browserstack. Please find below the code that should start the Local server, but which fails with

{ [LocalError: Could not connect to www.browserstack.com!]
  name: 'LocalError',
  message: 'Could not connect to www.browserstack.com!',
  extra: undefined }

My main question is: how do I have localhost:8000 displayed in browserstack.com? I have read many SO questions and blog posts with conflicting infos, the tests are maybe too explicit in the sense of "not user-story oriented enough" (sorry if that sounds harsh, it certainly is not meant to be).

I tried to use the hosts key in the config, without really knowing what it is relates to, but it didn't work. The example I provide is with proxyHost/Port, but it doesn't work either and anyway I doubt these are the correct keys.

    const browserstack = require('browserstack-local');
    const bsLocal = new browserstack.Local();
    return new Promise((resolve, reject)=> {
      const config = {
        proxyHost: '127.0.0.1',
        proxyPort: 8000,
        key: this.credentials.key,
        v: true
      };
      console.log('starting BS Local', config);
      bsLocal.start(config, (error)=> {
        console.log('Local started');
        if (error) {
          reject(error);
        }
        resolve(bsLocal);
      });
    })

I really hope you will be able to help me finding the right setup, I have to rely on not very elegant tunneling solutions in the mean time.

xcambar commented 8 years ago

Found my answer here: https://github.com/browserstack/nightwatch-browserstack/blob/master/tests/local/local_test.js

Obviously, I found it 3 min after posting the issue... as always 😆

HouCoder commented 7 years ago

So local http server also available at http://bs-local.com:45691 on BrowserStack?

punitx commented 7 years ago

@HouCoder bs-local.com resolves to 127.0.0.1 so if you have any server running on port 45691 then yes, it will be available on BrowserStack via http://bs-local.com:45691. Otherwise, just http://localhost:<port> should work fine 😄

HouCoder commented 7 years ago

@punitx I did some thing wrong in my code, I've fixed it and it works now, thanks for your response.

sergio-domingues commented 5 years ago

Is it posible to specify the port where the local http server will be listening?