[ https://issues.apache.org/jira/browse/THRIFT-2529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13996574#comment-13996574 ]
Randy Abernethy commented on THRIFT-2529: ----------------------------------------- This is an old bug. Unfortunately it is still alive in the current release (0.9.1). In the current dev master this bug is not present. To switch to the dev code you can copy the .js source files from here: https://github.com/apache/thrift/tree/master/lib/nodejs/lib/thrift into your node_modules/thrift/lib/thrift directory (overwritting the 0.9.1 files). Then you will need to add the q library (a new dependency) to the node_modules/thrift/node_modules directory (you can just "npm install q" from the node_modules/thrift directory. When Thrift 0.9.2 is released you can simply "npm install thrift" and everything will work as expected. I reproed your problem with the code below and verified that it works fine with the current dev master: {code:title=test.thrift} namespace js com.thrift struct User { 1: i32 uid, 2: string name, 3: i16 age, 4: string desc } service UserService { string add(1: User user) } {code} {code:title=client.js} var thrift = require('thrift'); var svc = require('./gen-nodejs/UserService.js'); var types = require('./gen-nodejs/test_types.js'); var connection = thrift.createConnection('localhost', 8585, { transport: thrift.TBufferedTransport, protocol: thrift.TBinaryProtocol }).on('error', function(error) { console.log(error); }).on("connect", function() { var client = thrift.createClient(svc, connection); var user = new types.User({ uid: 42, name: "Bob", age: 22, desc: "gardener"}); client.add(user, function(err, response) { console.log("response-1:", response); }); user.uid = 43; user.name = "Ann"; client.add(user, function(err, response) { console.log("response-2:", response); }); user.uid = 44; user.name = "Lee"; client.add(user, function(err, response) { console.log("response-3:", response); connection.end(); }); }); {code} {code:title=server.js} var thrift = require('thrift'); var svc = require('./gen-nodejs/UserService.js'); var svcHandler = { add: function (user, result) { console.log("Received: " + user); result(null, "Hello " + user.name); } }; var serverOpt = { protocol: thrift.TBinaryProtocol, transport: thrift.TBufferedTransport } var port = 8585; thrift.createServer(svc, svcHandler, serverOpt) .on('error', function(error) { console.log(error); }) .listen(port); console.log("Thrift Server running on port: " + port); {code} > TBufferedTransport split Tcp data bug in nodeJs > ------------------------------------------------ > > Key: THRIFT-2529 > URL: https://issues.apache.org/jira/browse/THRIFT-2529 > Project: Thrift > Issue Type: Bug > Environment: centos nodeJsv0.10.24 thrift0.9.1 > Reporter: my_program > Fix For: 0.9.2 > > > when i use TBufferedTransport in client and server, the problem is: > 1)my thrift file is :namespace js com.thrift > struct User { > 1: i32 uid, > 2: string name, > 3: i16 age, > 4: string desc > } > service UserService { > string add(1: User user) > } > 2) client: > I execute add() method 3 times, but response is only 1 times. > for example: > client.add(user, function(err, response) { > console.log("response-1:", response); > }); > client.add(user, function(err, response) { > console.log("response-2:", response); > }); > client.add(user, function(err, response) { > console.log("response-3:", response); > }); > Please help me to solve this problem! -- This message was sent by Atlassian JIRA (v6.2#6252)