Skip to content

Commit

Permalink
fix: workaround for zeromq connection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Jun 20, 2023
1 parent 1737d79 commit 5d07a3d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/services/dashd.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,25 @@ 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 timeout = setTimeout(function () {
// neither accepting nor rejecting - either invalid or firewalled (DROP)
log.error(`ZMQ address '${zmqUrl}' cannot be reached`);
process.exit(1);
}, 5 * 1000);

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) {
Expand Down

0 comments on commit 5d07a3d

Please sign in to comment.