modify default timeout to 120 seconds and add in enironment variable to allow changing it

This commit is contained in:
David Kebler 2019-05-01 15:34:07 -07:00
parent 456b9568ff
commit ccf9ab8c8a

View file

@ -49,7 +49,7 @@ class SocketConsumer extends Socket {
// if keepAlive is true then consumer will also be reconnecting consumer
this.keepAlive = 'keepAlive' in opts ? opts.keepAlive : true
this._ready = false
this.timeout = opts.timeout || 60 // initial connect timeout in secs and then rejects
this.timeout = opts.timeout || process.env.UCI_CONNECT_TIMEOUT || 120 // initial connect timeout in secs and then rejects
this.wait = opts.wait || 2
this.stream = new JsonStream()
// bind to class for other class functions
@ -67,10 +67,7 @@ class SocketConsumer extends Socket {
// this is only for initial connection
const initTimeout = setTimeout(() => {
log.fatal({method:'connect', line:69, opts: this.opts, msg:`unable to connect in ${this.timeout}s`})
reject(
{ opts: this.opts },
`unable to connect to socket server in ${this.timeout}secs`
)
reject({ opts: this.opts },`unable to connect to socket server in ${this.timeout}secs`)
}, this.timeout * 1000)