Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround for zeromq connection bug #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/services/dashd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
shumkov marked this conversation as resolved.
Show resolved Hide resolved
}, 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) {
Expand Down