在thrift节点js中是否存在客户端超时

时间:2017-06-05 12:28:09

标签: node.js thrift

thrift节点js是否提供客户端时间或默认超时? 无法找到任何相关的例子。

使用以下客户端代码:

var thrift = require('thrift');
var MultiplicationService = require("./gen-nodejs/MultiplicationService");

var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection("localhost", 9090, {
    transport : transport,
    protocol : protocol
});

connection.on('error', function(err) {
    assert(false, err);
});

var client = thrift.createClient(MultiplicationService, connection);

client.multiply(2,3, function(err, response) {
    console.log("2*3=" + response);
});

1 个答案:

答案 0 :(得分:0)

您可以使用一些选项

 var connection = thrift.createConnection("localhost", 9090, {
    transport : transport,
    protocol : protocol,
    connect_timeout: 100,
    max_attempts: 2 
});

查看此文件以获取更多信息https://github.com/apache/thrift/blob/c035eca3c672511779440bd0779ce5bc93d5c327/lib/nodejs/lib/thrift/connection.js