Naturally Pacifist Marsupials

    try-net-connect

    3.0.2 • Public • Published

    try-net-connect

    I use this in my startup scripts executed in Docker containers so that I can wait for another container's server to be ready before starting the dependent server.

    Install

    npm install try-net-connect
    

    Usage

    const tryConnect = require('try-net-connect')
     
    tryConnect({
      host: process.env.HOST,
      port: process.env.PORT
    }).on('connected', win)
      .on('retry', tryToWin)
      .on('timeout', feelBad)

    tryConnect(options)

    See node's net.connect parameters for connection options.

    • options: object
      • retry: number, 1000 ms to wait before retrying connection
      • retries: number, null (infinite) number of retries
    • returns: eventEmitter
      • .on('connected', client => {})
      • .on('retry', reason => {})
      • .on('timeout', mainReason => {})
      • stop: function stop retrying

    Install

    npm i try-net-connect

    DownloadsWeekly Downloads

    48

    Version

    3.0.2

    License

    CC0-1.0

    Last publish

    Collaborators

    • m59