Reputation: 11
How to implement client side multiplexing using thrift in nodejs?
I tried the below code, but in vain.
var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;
var multiplexer = thrift.Multiplexer;
var ip = 'localhost';
var port = 9090;
var connection = thrift.createConnection(ip, port, {
transport : transport,
protocol : protocol
});
multiplexer();
var client = multiplexer.prototype.createClient(
"myServiceName", myServiceClient, connection
);
When I use the above client and call a method/function that is defined in my service, connection is being made smoothly (no connection error) and service method/function runs smoothly and returns the output. But upon receiving the data (buffered) connection.js in thrift npm module throws "Cannot set property '0' of undefined" error. On further investigation I found that seqid which is set on each client creation, is not being set.
Can someone please help me on this?
Upvotes: 1
Views: 817
Reputation: 106
I found this to be the solution for the client:
var transport = thrift.TBufferedTransport;
var protocol = thrift.TBinaryProtocol;
var multiplexer = thrift.Multiplexer;
var ip = 'localhost';
var port = 9090;
var connection = thrift.createConnection(ip, port, {
transport : transport,
protocol : protocol
});
var multiplexer = new thrift.Multiplexer();
var client = multiplexer.createClient(
"myServiceName", myServiceClient, connection
);
Upvotes: 2