Skip to content

Commit 5d07a3d

Browse files
committed
fix: workaround for zeromq connection bug
1 parent 1737d79 commit 5d07a3d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/services/dashd.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,25 @@ Dash.prototype._initZmqSubSocket = function(node, zmqUrl) {
802802
var self = this;
803803
node.zmqSubSocket = zmq.socket('sub');
804804

805+
log.info(`ZMQ opening socket to '${zmqUrl}'`);
806+
807+
// workaround for https://github.com/zeromq/zeromq.js/issues/574
808+
var timeout = setTimeout(function () {
809+
// neither accepting nor rejecting - either invalid or firewalled (DROP)
810+
log.error(`ZMQ address '${zmqUrl}' cannot be reached`);
811+
process.exit(1);
812+
}, 5 * 1000);
813+
805814
node.zmqSubSocket.on('connect', function(fd, endPoint) {
806815
log.info('ZMQ connected to:', endPoint);
816+
clearTimeout(timeout);
817+
timeout = null;
807818
});
808819

809820
node.zmqSubSocket.on('connect_delay', function(fd, endPoint) {
810821
log.warn('ZMQ connection delay:', endPoint);
822+
clearTimeout(timeout);
823+
timeout = null;
811824
});
812825

813826
node.zmqSubSocket.on('disconnect', function(fd, endPoint) {

0 commit comments

Comments
 (0)