Skip to content

Commit a01e2b7

Browse files
committed
fix: workaround for zeromq connection bug
1 parent dfbe76e commit a01e2b7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/services/dashd.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,12 +802,26 @@ 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 tcpTimeout = 5 * 1000;
809+
var timeout = setTimeout(function () {
810+
// neither accepting nor rejecting - either invalid or firewalled (DROP)
811+
log.error(`ZMQ address '${zmqUrl}' cannot be reached`);
812+
process.exit(1);
813+
}, tcpTimeout);
814+
805815
node.zmqSubSocket.on('connect', function(fd, endPoint) {
806816
log.info('ZMQ connected to:', endPoint);
817+
clearTimeout(timeout);
818+
timeout = null;
807819
});
808820

809821
node.zmqSubSocket.on('connect_delay', function(fd, endPoint) {
810822
log.warn('ZMQ connection delay:', endPoint);
823+
clearTimeout(timeout);
824+
timeout = null;
811825
});
812826

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

0 commit comments

Comments
 (0)