thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michi Mutsuzaki <mic...@yahoo-inc.com>
Subject java: using binary and TFramedTransport
Date Mon, 25 Apr 2011 20:52:44 GMT
Hello,

I'm having trouble using binary type with TFramedTransport in Java. I'm
using Thrift 0.6. I have a method that takes a binary as an argument:

    i32 myMethod(1:binary blob),

I have a Java client that calls myMethod():

    TSocket socket = new TSocket("localhost", 9090);
    TTransport transport = new TFramedTransport(socket);
    transport.open();
    TProtocol protocol = new TBinaryProtocol(transport);
    MyService.Client client = new MyService.Client(protocol);
    client.myMethod(ByteBuffer.wrap("hello".getBytes()));

The server is started like this:

    TServerTransport trans = new TServerSocket(port);
    TThreadPoolServer.Args args = new TThreadPoolServer.Args(trans);
    args.processor(new MyService.Processor(new MyProcessor()));
    args.transportFactory(new TFramedTransport.Factory());
    args.protocolFactory(new TBinaryProtocol.Factory(true, true));
    TServer server = new TThreadPoolServer(args);
    server.serve();

On the server side, myMethod() receives more than "hello". It looks
something like this:

    ?^A^@^A^@^@^@^KmyMethod^@^@^@^A^K^@^A^@^@^@^Chello^@

It works correctly if I don't use TFramedTransport. Am I misusing
TFramedTransport?

Thanks!
--Michi


Mime
View raw message