【发布时间】:2014-12-01 18:48:28
【问题描述】:
我编写了以下等待响应的代码。如果我在 5 秒后没有收到响应,如何注册超时回调?
var zmqRequest = zmq.socket('req');
zmqRequest.connect('tcp://localhost:8188');
zmqRequest.send(request.params.fileGuid);
console.log('request sent ' + request.params.fileGuid);
zmqRequest.on('message', function(msg){ // report back to the user... });
【问题讨论】:
-
你找到答案了吗?我试过 socket.setsockopt(zmq.ZMQ_RCVTIMEO, 1000); socket.setsockopt(zmq.ZMQ_SNDTIMEO, 1000);但它似乎不起作用。
-
@FredMériot 我在下面添加了我的答案。