Error implementing Thrift API

I am implementing the Thrift Remote Procedure call structure in Java. I tuned the thrift and generated skeletal code without a lot of problems, but now that I actually use the API methods, I get strange errors.

Here are the errors I get:

Exception in thread "main" org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:142)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:163)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:91)
at SimonSays$Client.send_registerClient(SimonSays.java:102)
at SimonSays$Client.registerClient(SimonSays.java:96)
at simon.main(testClass.java:16)

I do not think that I am not mistaken, but just to make sure, here is the code that leads to errors:

TProtocol prot = new TBinaryProtocol(new TSocket("http://thriftpuzzle.facebook.com",9030));
    SimonSays.Client client = new SimonSays.Client(prot);

    client.registerClient("userEmailAddress@gmail.com");

It is said that the error is caused by a call client.registerClient(), but it is a call to the code generated by Thrift, which makes me feel like I am doing something wrong in setting up the connection itself.

The part about creating the instance TProtocolthat I included, and probably this is where the problem is.

I was hoping that someone would have a better idea of ​​what was going on differently from me.

, , .

: TProtocol Cassandra Wiki

+3
1

open() TSocket, /, .

: TSocket.java

+2

Source: https://habr.com/ru/post/1775078/


All Articles