You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by jeevan kk <je...@gmail.com> on 2013/04/08 08:35:33 UTC

Getting TProtocolException: Invalid data with node.js thrift client on server side

Hi,
I am trying to use node.js thrift client. I am getting error on server side

TSimpleServer exception: N6apache6thrift8protocol18TProtocolExceptionE:
TProtocolException: Invalid data

How to fix this issue?

My sample .thrift file is:
struct Person{
1: required string name_;
2: required map<i64,string> attribute1_;
3: required map<i64,i64> attribute2_;
4: required map<i64,string> attribute3_;
}

service ProcessPerson {
 void DoPerson(
       1: required list<Person> person_array
         )
}


node.js client code is:
var thrift = require('thrift');
var ttransport = require('./node_modules/thrift/lib/thrift/transport.js');
var tprotocol = require('./node_modules/thrift/lib/thrift/protocol.js');
var b_conn = thrift.createConnection('localhost', 9090, {transport:
ttransport.TBufferedTransport ,protocol: tprotocol.TBinaryProtocol});
var ServicePerson = require('./person_js/ProcessPerson.js');
var type = require('./person_js/person_types');

b_conn.on('error', function(err) {
   console.error("error");
   console.error(err);
});

b_conn.on('connect', function(data) {
   console.log('on conect');
   var client = thrift.createClient(ServicePerson, b_conn);

   var person_list = new Array();
   var person_obj = new type.Person({name_:"aa",
attribute1_:"",attribute2_:"",attribute3_: ""  });


   console.log(person_obj);
   person_list.push(person_obj);
   client.DoPerson(person_list, function() {
       console.log("Hi");
   });

});

I am using skeleton file at server side.

-- 
*Regards
Jeevan KK*