Skip to content

PDMLab/net-retry-connect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

net-retry-connect

Attempt to connect to net Sockets using retry patterns.

net-retry-connect is based on the Node.js net module as well as the retry module.

Installation

npm install net-retry-connect --save

API

retryConnect.to(options, callback)

options provides this options:

  • port: the TCP port
  • host: optional, defaults to 'localhost'
  • retryOptions, optional, see retry options for retry.operation

callback returns a client object if connection has been successful. Otherwise it returns the error.

var retryConnect = require('net-retry-connect');
retryConnect.to({port: 3000, host: 'localhost'}, function (error, client) {
    // use the client
});

Usage of retryOptions

var retryConnect = require('net-retry-connect');

// retry for 2 seconds only
var retryOptions = {
  retries: 2,
  factor: 1
};

retryConnect.to({port: 3000, host: 'localhost', retryOptions: retryOptions }, function (error, client) {
    // use the client
});

Running the tests:

npm install   
npm test

About

Attempt to connect to net Sockets using retry patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published