1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00
OpenSTF/lib/util/zmqutil.js
Simo Kinnunen b248e96dc2 Output a warning instead of crashing if ZMQ library is too old to
support TCP keepalive options. Fixes #109.
2015-10-14 01:40:30 +09:00

23 lines
601 B
JavaScript

// ISSUE-100 (https://github.com/openstf/stf/issues/100)
// In some networks TCP Connection dies if kept idle for long.
// Setting TCP_KEEPALIVE option true, to all the zmq sockets
// won't let it die
var zmq = require('zmq')
var log = require('./logger').createLogger('util:zmqutil')
module.exports.socket = function() {
var sock = zmq.socket.apply(zmq, arguments)
try {
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE, 1)
sock.setsockopt(zmq.ZMQ_TCP_KEEPALIVE_IDLE, 300000)
}
catch (err) {
log.warn('ZeroMQ library too old, no support for TCP keepalive options')
}
return sock
}