GithubHelp home page GithubHelp logo

node-tunnel's Introduction

LambdaTest Logo

LambdaTest Nodejs bindings for Tunnel

Node Tunnel health check

Installation

npm i @lambdatest/node-tunnel

Example

var lambdaTunnel = require('@lambdatest/node-tunnel');

//Creates an instance of Tunnel
var tunnelInstance = new lambdaTunnel();

// Replace <lambdatest-user> with your user and <lambdatest-accesskey> with your key.
var tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>'
};

// Callback Style
// Atarts the Tunnel instance with the required arguments
tunnelInstance.start(tunnelArguments, function(error, status) {
  if (!error) {
    console.log('Tunnel is Running Successfully');
  }
});

// Promise Style
tunnelInstance
  .start(tunnelArguments)
  .then(status => {
    console.log('Tunnel is Running Successfully');
  })
  .catch(error => {
    console.log(error);
  });

// Async/Await Style
(async function() {
  try {
    const istunnelStarted = await tunnelInstance.start(tunnelArguments);
    console.log('Tunnel is Running Successfully');
  } catch (error) {
    console.log(error);
  }
})();

Methods

tunnelInstance.start(tunnelArguments, callback)

Start tunnel Instance.

  • tunnelArguments: credentials for secure tunnel connection.
    • user: The username for the LambdaTest account.
    • key: The accessKey for the LambdaTest account.
  • callback (function(error, status)): A callback to invoke when the API call is complete.
// Callback Style
tunnelInstance.start(tunnelArguments, function(error, status) {
  if (!error) {
    console.log('Tunnel is Running Successfully');
  }
});

// Promise Style
tunnelInstance
  .start(tunnelArguments)
  .then(status => {
    console.log('Tunnel is Running Successfully');
  })
  .catch(error => {
    console.log(error);
  });

// Async/Await Style
(async function() {
  try {
    const istunnelStarted = await tunnelInstance.start(tunnelArguments);
    console.log('Tunnel is Running Successfully');
  } catch (error) {
    console.log(error);
  }
})();

tunnelInstance.isRunning()

Get Status of tunnel Instance.

// Callback Style
tunnelInstance.start(tunnelArguments, function(error, status) {
  if (!error) {
    console.log('Tunnel is Running Successfully');
    var tunnelRunningStatus = tunnelInstance.isRunning();
    console.log('Tunnel is Running ? ' + tunnelRunningStatus);
  }
});

// Promise Style
tunnelInstance
  .start(tunnelArguments)
  .then(status => {
    console.log('Tunnel is Running Successfully');
    const tunnelRunningStatus = tunnelInstance.isRunning();
    console.log('Tunnel is Running ? ' + tunnelRunningStatus);
  })
  .catch(error => {
    console.log(error);
  });

// Async/Await Style
(async function() {
  try {
    const istunnelStarted = await tunnelInstance.start(tunnelArguments);
    console.log('Tunnel is Running Successfully');
    const tunnelRunningStatus = tunnelInstance.isRunning();
    console.log('Tunnel is Running ? ' + tunnelRunningStatus);
  } catch (error) {
    console.log(error);
  }
})();

tunnelInstance.getTunnelName(callback)

Get name of the Running tunnel Instance.

  • callback (function(tunnelName)): A callback to invoke when the API call is complete.
// Callback Style
tunnelInstance.start(tunnelArguments, function(error, status) {
  if (!error) {
    console.log('Tunnel is Running Successfully');
    tunnelInstance.getTunnelName(function(tunnelName) {
      console.log('Tunnel Name : ' + tunnelName);
    });
  }
});

// Promise Style
tunnelInstance
  .start(tunnelArguments)
  .then(status => {
    console.log('Tunnel is Running Successfully');
    tunnelInstance.getTunnelName().then(tunnelName => {
      console.log('Tunnel Name : ' + tunnelName);
    });
  })
  .catch(error => {
    console.log(error);
  });

// Async/Await Style
(async function() {
  try {
    const istunnelStarted = await tunnelInstance.start(tunnelArguments);
    console.log('Tunnel is Running Successfully');
    const tunnelName = await tunnelInstance.getTunnelName();
    console.log('Tunnel Name : ' + tunnelName);
  } catch (error) {
    console.log(error);
  }
})();

tunnelInstance.stop(callback)

Stop the Running tunnel Instance.

  • callback (function(error, status)): A callback to invoke when the API call is complete.
// Callback Style
tunnelInstance.start(tunnelArguments, function(error, status) {
  if (!error) {
    console.log('Tunnel is Running Successfully');
    tunnelInstance.stop(function(error, status) {
      console.log('Tunnel is Stopped ? ' + status);
    });
  }
});

// Promise Style
tunnelInstance
  .start(tunnelArguments)
  .then(status => {
    console.log('Tunnel is Running Successfully');
    tunnelInstance.stop().then(status => {
      console.log('Tunnel is Stopped ? ' + status);
    });
  })
  .catch(error => {
    console.log(error);
  });

// Async/Await Style
(async function() {
  try {
    const istunnelStarted = await tunnelInstance.start(tunnelArguments);
    console.log('Tunnel is Running Successfully');
    const status = await tunnelInstance.stop();
    console.log('Tunnel is Stopped ? ' + status);
  } catch (error) {
    console.log(error);
  }
})();

Arguments

Every modifier except user and key is optional. Visit LambdaTest tunnel modifiers for an entire list of modifiers. Below are demonstration of some modifiers for your reference.

LambdaTest Basic Credentials

Below credentials will be used to perform basic authentication of your LambdaTest account.

  • user (Username of your LambdaTest account)
  • key (Access Key of your LambdaTest account)

Port

If you wish to connect tunnel on a specific port.

  • port : (optional) Local port to connect tunnel.
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  port: '<port>'
};

Proxy

If you wish to perform tunnel testing using a proxy.

  • proxyhost: Hostname/IP of proxy, this is a mandatory value.
  • proxyport: Port for the proxy, by default it would consider 3128 if proxyhost is used For Basic Authentication, we use the below proxy options:
  • proxyuser: Username for connecting to proxy, mandatory value for using 'proxypass'
  • proxypass: Password for the USERNAME option.
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  proxyHost: '127.0.0.1',
  proxyPort: '8000',
  proxyUser: 'user',
  proxyPass: 'password'
};

Tunnel Name

Human readable tunnel identifier

  • tunnelName: (Name of the tunnel)
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  tunnelName: '<your-tunnel-name>'
};

Testing Local Folder

Populate the path of the local folder you want to test in your internal server as a value in the below modifier.

  • dir/localdir/localdirectory : Path of the local folder you want to test
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  dir: '<path of the local folder you want to test>'
};

Enable Verbose Logging

To log every request to stdout.

  • v/verbose : true or false
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  v: true
};

Additional Arguments

Logfile You can provide a specific path to this file. If you won't provide a path then the logs would be saved in your present working directory by the filename: tunnel.log. For providing a specific path use the below argument:

  • logFile : path
tunnelArguments = {
  user: process.env.LT_USERNAME || '<lambdatest-user>',
  key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>',
  logFile: '/lambdatest/logs.txt'
};
  • egressOnly: Uses proxy settings only for outbound requests.
  • ingressOnly: Uses proxy settings only for inbound requests.
  • dns: Comma separated list of dns servers
  • sshConnType: Specify type of ssh connection (over_22, over_443, over_ws)
  • mode: Specifies in which mode tunnel should run [ssh,ws]
  • nows: Force tunnel to run in non websocket mode
  • mitm: MITM mode, used for testing websites with private certificates

Contribute

Reporting bugs

Our GitHub Issue Tracker will help you log bug reports.

Tips for submitting an issue: Keep in mind, you don't end up submitting two issues with the same information. Make sure you add a unique input in every issue that you submit. You could also provide a "+1" value in the comments.

Always provide the steps to reproduce before you submit a bug. Provide the environment details where you received the issue i.e. Browser Name, Browser Version, Operating System, Screen Resolution and more. Describe the situation that led to your encounter with bug. Describe the expected output, and the actual output precisely.

Pull Requests

We don't want to pull breaks in case you want to customize your LambdaTest experience. Before you proceed with implementing pull requests, keep in mind the following. Make sure you stick to coding conventions. Once you include tests, ensure that they all pass. Make sure to clean up your Git history, prior your submission of a pull-request. You can do so by using the interactive rebase command for committing and squashing, simultaneously with minor changes + fixes into the corresponding commits.

About LambdaTest

LambdaTest is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your selenium automation testing to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.

node-tunnel's People

Contributors

4dvanceboy avatar danielharoldlane avatar dubesar avatar hranjan-11 avatar kanhaiya15 avatar muditlambda avatar nikhil-lambda avatar psych0der avatar shahnawaz-sk avatar shivanshu-lambdatest avatar ssrahman avatar vanshmadan-devops avatar vikas-lt avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-tunnel's Issues

Upgrade instructions

I'm getting the following message when starting a tunnel:

It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel

But I'm using the latest published release. Does the latest version of the tunnel need to be published?

I'm also getting some random failures where it says the tunnel wasn't started or was closed even though it was started and wasn't closed.

Cannot establish tunnel connection - Mac M1

Hello there, when I try the script provided in your README.md it instantly fails. I guess it has something to do with that fact that I am running on Mac with a new M1 chip. Looks like you don't provide binaries for this architecture.

Node: 16.0.0
OS: MacOS Big Sur 11.4
@lambdatest/node-tunnel: 3.0.1

Output:

joozty@Jozefs-MacBook-Pro node-tunnel % node test.js                                        

It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel
Verifying credentials

It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel
Verifying credentials

It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel
Verifying credentials
Auth succeeded
Checking for updates
Binary is deprecated
Downloading latest binary
Auth succeeded
Downloading latest binary
Auth succeeded
Downloading latest binary
Extracting binary
Retrying Download. Retries left 5
Downloading latest binary
Extracting binary
Extracting binary
Extracting binary
Starting tunnel
node:internal/child_process:415
    throw errnoException(err, 'spawn');
    ^

Error: spawn Unknown system error -86
    at ChildProcess.spawn (node:internal/child_process:415:11)
    at Object.spawn (node:child_process:609:9)
    at /Users/joozty/Documents/sandboxes/node-tunnel/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:314:32
    at /Users/joozty/Documents/sandboxes/node-tunnel/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:730:18
    at /Users/joozty/Documents/sandboxes/node-tunnel/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:767:14
    at Object.onceWrapper (node:events:471:28)
    at Server.emit (node:events:365:28)
    at emitCloseNT (node:net:1648:8)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -86,
  code: 'Unknown system error -86',
  syscall: 'spawn'
}

Is this still supported?

I'm trying to use this but it doesn't seem to be working even though the output says "Tunnel successfully initiated. You can start testing now" and I can't find documentation on LambdaTest for using this specifically.

ETIMOUT on running test

Hi,

Since today, we've got systematic timeouts as soon as the tunnel is launched. Nothing has changed on our code nor on our infrastructure. And we don't see the tunnel being created on LT

Here is the log :

$ cucumber-js --require-module @babel/register --fail-fast --world-parameters='{"browser": "chrome"}'
68 Verifying credentials
69 Auth succeeded
70 Downloading latest binary
71 Extracting binary
72 Starting tunnel
73 Tunnel successfully initiated. You can start testing now
74 ..(node:460) UnhandledPromiseRejectionWarning: WebDriverError: {"message":"connect ETIMEDOUT"}
75     at Object.checkLegacyResponse (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/error.js:585:15)
76     at parseHttpResponse (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/http.js:554:13)
77     at Executor.execute (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/http.js:489:26)
78     at runMicrotasks (<anonymous>)
79     at processTicksAndRejections (internal/process/task_queues.js:93:5)
80 (node:460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
81 (node:460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
82 (node:460) UnhandledPromiseRejectionWarning: WebDriverError: {"message":"connect ETIMEDOUT"}
83     at Object.checkLegacyResponse (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/error.js:585:15)
84     at parseHttpResponse (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/http.js:554:13)
85     at Executor.execute (/builds/famihero-web/famihero-web/node_modules/selenium-webdriver/lib/http.js:489:26)
86     at runMicrotasks (<anonymous>)
87     at processTicksAndRejections (internal/process/task_queues.js:93:5)
88 (node:460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)

TypeScript definitions appears to be incorrect

TS definitions do not match method usage in docs. For example, the docs describe both callback and promise compatibility for the stop method. Based on the docs, the TS definitions should be stop(callback: (err?: Error, status: string) => void): Promise<void>;. Instead, it's stop(callback: () => void): void;.

Tag releases

Would it be possible to git tag releases, so that comparing changes between release would be easier?
Currently there are no tags at all, but npm has:

$ npm info @lambdatest/node-tunnel versions
[ '1.0.0', '1.0.1', '1.0.2', '1.0.3' ]

A few suggestions

  1. update dependencies
  2. fix CI
  3. fix lint
  4. establish supported Node.js versions
  5. bonus see if you can reduce your dependencies/devDependencies and sort out any open PRs :)

Error: spawn Unknown system error -8 after node-tunnel 4.0.0 release

Our pipeline stopped working properly few our ago - cca at the same time as the 4.0.0 release of the tunnel.

The error is:

Current version of Node Tunnel:  3.0.14
It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using: 
npm update @lambdatest/node-tunnel
Verifying credentials
Auth succeeded
Downloading latest binary
Extracting binary
Starting tunnel
Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at Object.spawn (node:child_process:757:9)
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:342:32
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:773:18
    at /data/src/node_modules/wdio-lambdatest-service/node_modules/@lambdatest/node-tunnel/lib/tunnel.js:810:14
    at Object.onceWrapper (node:events:627:28)
    at Server.emit (node:events:513:28)
    at Server.emit (node:domain:489:12)
    at emitCloseNT (node:net:2135:8)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)

Could this be related to the release?

Bogus new version message

It's seems you have older version of @lambdatest/node-tunnel.For better experience , please update using:

This shows up even though we are using the latest npm version 3.0.14.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.