From 8e8f2d17b7b8517f1b6d49ebcc4f676a0651e483 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Wed, 21 Oct 2015 20:13:45 +0900 Subject: [PATCH] Make ZMQ keepalive options optional, since they're breaking things on some systems. You should now use the ZMQ_TCP_KEEPALIVE=1 and ZMQ_TCP_KEEPALIVE_IDLE= environment variables to set them. --- lib/util/zmqutil.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/util/zmqutil.js b/lib/util/zmqutil.js index 8c5fc39c..c8e2e312 100644 --- a/lib/util/zmqutil.js +++ b/lib/util/zmqutil.js @@ -11,13 +11,16 @@ 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') - } + ;['ZMQ_TCP_KEEPALIVE', 'ZMQ_TCP_KEEPALIVE_IDLE'].forEach(function(opt) { + if (process.env[opt]) { + try { + sock.setsockopt(zmq[opt], +process.env[opt]) + } + catch (err) { + log.warn('ZeroMQ library too old, no support for %s', opt) + } + } + }) return sock }