From 43adeed2355a8aad54910b8ec86128bb16205901 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 20 Jun 2023 02:25:01 -0600 Subject: [PATCH] fix: workaround for zeromq connection bug --- lib/services/dashd.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/services/dashd.js b/lib/services/dashd.js index adc2d12bc..44e75c23b 100644 --- a/lib/services/dashd.js +++ b/lib/services/dashd.js @@ -802,12 +802,26 @@ Dash.prototype._initZmqSubSocket = function(node, zmqUrl) { var self = this; node.zmqSubSocket = zmq.socket('sub'); + log.info(`ZMQ opening socket to '${zmqUrl}'`); + + // workaround for https://github.com/zeromq/zeromq.js/issues/574 + var tcpTimeout = 5 * 1000; + var timeout = setTimeout(function () { + // neither accepting nor rejecting - either invalid or firewalled (DROP) + log.error(`ZMQ address '${zmqUrl}' cannot be reached`); + process.exit(1); + }, tcpTimeout); + node.zmqSubSocket.on('connect', function(fd, endPoint) { log.info('ZMQ connected to:', endPoint); + clearTimeout(timeout); + timeout = null; }); node.zmqSubSocket.on('connect_delay', function(fd, endPoint) { log.warn('ZMQ connection delay:', endPoint); + clearTimeout(timeout); + timeout = null; }); node.zmqSubSocket.on('disconnect', function(fd, endPoint) {