exposes pollTimeout property

This commit is contained in:
Sam Eaton 2017-08-02 08:44:59 -07:00
parent b82f249402
commit 068dd11b58
4 changed files with 29 additions and 11 deletions

View file

@ -290,6 +290,26 @@ autossh({
<br />
#### Adjusting Poll Timeout
Autossh will attempt to establish a connection every *n* milliseconds until a connection is established. To increase the time between each attempt, set the `pollTimeout` option in the configuration.
The following will attempt to connect every second (1000 ms) up to 50 times before giving up:
```javascript
autossh({
host: '111.22.333.444',
username: 'root',
localPort: 'auto',
remotePort: 5432,
maxPollCount: 50,
pollTimeout: 1000
})
.on('connect', connection => {
console.log('connected: ', connection);
})
```
#### Specifying a Different SSH Port
The designated port for SSH according to the Transmission Control Protocol (TCP) is port 22, but you can specify a different port if you are using a different port. Set the `sshPort` property in the object you pass to `autossh`.
@ -302,4 +322,4 @@ autossh({
remotePort: 5432,
sshPort: 9999
});
```
```

View file

@ -1,6 +1,6 @@
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@ -22,19 +22,17 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
/* AutoSSH class
*/
var AutoSSH = function (_EventEmitter) {
_inherits(AutoSSH, _EventEmitter);
/*
*/
function AutoSSH() {
var conf = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var conf = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, AutoSSH);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AutoSSH).call(this));
var _this = _possibleConstructorReturn(this, (AutoSSH.__proto__ || Object.getPrototypeOf(AutoSSH)).call(this));
_this.configure(conf);
@ -66,8 +64,8 @@ var AutoSSH = function (_EventEmitter) {
if (this.reverse) this.localPort = parseInt(conf.localPort) || 22;else this.localPort = conf.localPort || 'auto';
this.pollCount = 0;
this.maxPollCount = conf.maxPollCount || 30;
this.pollTimeout = 75;
this.maxPollCount = parseInt(conf.maxPollCount) || 30;
this.pollTimeout = parseInt(conf.pollTimeout) || 75;
this.serverAliveInterval = typeof conf.serverAliveInterval === 'number' ? conf.serverAliveInterval : 120;

View file

@ -1,6 +1,6 @@
{
"name": "autossh",
"version": "0.0.16",
"version": "0.1.0",
"description": "Persistent SSH tunnels",
"main": "index.js",
"scripts": {

View file

@ -39,8 +39,8 @@ class AutoSSH extends EventEmitter {
this.localPort = conf.localPort || 'auto';
this.pollCount = 0;
this.maxPollCount = conf.maxPollCount || 30;
this.pollTimeout = 75;
this.maxPollCount = parseInt(conf.maxPollCount) || 30;
this.pollTimeout = parseInt(conf.pollTimeout) || 75;
this.serverAliveInterval = typeof conf.serverAliveInterval === 'number' ?
conf.serverAliveInterval : 120;