I'm trying to use thrift to relalize communication between nodejs client 
and Java server

Thrift offer different kinds of java server which have been implemented
· TSimpleServer
· TNonblockingServer
· THsHaServer
· TThreadedSelectorServer
· TThreadPoolServer

I have successfully used nodejs client to call the function in 
TTSimpleServer and TThreadPoolServer which both use TServerSocket to 
initialize

    TServerSocket serverTransport = new TServerSocket(9090);
    
    CalculatorService.Processor<CalculatorImpl> processor = new 
CalculatorService.Processor<CalculatorImpl>(
    new CalculatorImpl());
    
    TThreadPoolServer.Args args = new 
TThreadPoolServer.Args(serverTransport).processor(processor);
    args.maxWorkerThreads(100);
    
    TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(
    serverTransport).processor(processor));
    
    System.out.println("Starting server on port 9090 ...");
    server.serve();


but when I try to use TNonblockingServer,TThreadedSelectorServer and 
THaHsServer ,  I came acrross following error in nodejs client



>     { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', 
syscall: 'read' }

I realized that this may be caused by TNonblockingSocket, is there any 
method to use nodejs communicate with TNonblockingSocket

    try
    {
    TNonblockingServerTransport serverTransport = new 
TNonblockingServerSocket(
    9090);
    
    CalculatorService.Processor<CalculatorImpl> processor = new 
CalculatorService.Processor<CalculatorImpl>(
    new CalculatorImpl());
    
    TServer server = new TThreadedSelectorServer(new 
TThreadedSelectorServer.Args(
    serverTransport).processor(processor));
    System.out.println("Starting server on port 9090 ...");
    server.serve();
    } catch (TTransportException e)
    {
    e.printStackTrace();
    }

my nodejs client code is as follow

     var thrift = require('thrift');

    var ThriftTransports = require('thrift/transport');
    var ThriftProtocols = require('thrift/protocol');
    var Calculator = require('./gen-nodejs/CalculatorService.js');
    var ttypes = require('./gen-nodejs/tutorial_types');
    
    transport = ThriftTransports.TFramedTransport();
    protocol = ThriftProtocols.TBinaryProtocol();
    
    var connection = thrift.createConnection("localhost", 9090, {
      transport : transport,
      protocol : protocol
    });
    
    connection.on('error', function(err) {
      console.log(err)
    });
    
    // Create a Calculator client with the connection
    var client = thrift.createClient(Calculator, connection);
    
    client.send_print(1,1, function(err, response) {
      console.log("send_print result:" + response);
    });


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/7c2b4def-f7dd-47a6-bd0d-1c6127e9fc51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to