You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Wilm Schumacher <wi...@cawoom.com> on 2013/08/07 13:43:06 UTC

Newbie Question: getting thrift-service running (c++/nodejs)

Hi,

I'm new to thrift, and I have a little trouble getting everything running.

At first the requirement: I want to get a c++-thrift-server running and
call it by a node.js client.

For that purpose I designed this "service":

## test.thrift ##
namespace cpp test

struct Message2Server {
	1: string message
}

struct Message2Client {
	1: string message
}

service test {
  Message2Client ping( 1:Message2Server message )
}
##################

where I uses the two structs "Message2..." to simulate different more
complicated in- and outputs, but here it actually only swaps strings for
the purpose of testing.

The client.cpp, server.cpp, client.js and server.js are found here (with
the thrift file is included and where thrift is already run)
https://lserv.uni-jena.de/upload-data/5202322b44bd7/test.zip

I only swap a Message2Server and a Message2Client. With a "ping"-"pong"

When I run the cpp-server and call it by the cpp-client everything is
fine. I get my "ping"-"pong".

But: when I run the node-server and call it with the node-client I get
my "ping". However ... the "pong" won't arrive. I get a "ping failed:
unknown result". Obviously the object I send is wrong. But what do I wrong?

If I run the node-server and call it with the cpp-client I get an error
from the server,
"read(4) failed - not enough data"
and from the client
"ERROR: No more data to read."

If I run the cpp-server and call it with the node-client I get an error
from the server nothing happens. It seems that both sides wait for
input. And if I kill the client, I get the error from the server
"Thrift: Wed Aug  7 13:28:37 2013 TSimpleServer client died: No more
data to read." (of course)

Obviously I do something wrong. And I think it is on the "node"-side of
the code. Unfortunately the official documentation for "thrift-node" is
not too extensive and I didn't found any help, thus I wrote this message.

If my question is already answered, or if I should read some
documentation, I would be very happy for any hints.

Thanks for reading and best wishes

Wilm

Re: Newbie Question: getting thrift-service running (c++/nodejs)

Posted by Henrique Mendonça <he...@apache.org>.
No problem, that's why we have the lists! This is a known bug and it's a
shame it's like that. We should have a look on it and fix it but I won't
have time any time soon.
But patches are always welcome, in case you have any improvements on this
or any other problem ;)

Cheers,
Henrique



On 7 August 2013 15:25, Wilm Schumacher <wi...@cawoom.com> wrote:

> Hi,
>
> at first I found another bug in my code (for completeness) in the
> server.js.
>
> Line 20: "success( message );"
> has to be of course
> Line 20: "success( null , message );"
>
> Am 07.08.2013 13:55, schrieb Henrique Mendonça:
> > Apparently you're using the default and buggy BufferedTransport...
> > Have you try using TFramedTransport?
> > you can have a look on the tests for an example:
> > https://github.com/apache/thrift/tree/master/test/nodejs
>
> That was the "problem". I switched in cpp and in the node code to Framed
> transport ... and it works :D.
>
> I searched the error for days by now, and you found the solution in 9
> minutes. Thanks a lot and I owe you now a box of german beer ;).
>
> Best wishes and many thanks
>
> Wilm
>

Re: Newbie Question: getting thrift-service running (c++/nodejs)

Posted by Wilm Schumacher <wi...@cawoom.com>.
Hi,

at first I found another bug in my code (for completeness) in the server.js.

Line 20: "success( message );"
has to be of course
Line 20: "success( null , message );"

Am 07.08.2013 13:55, schrieb Henrique Mendonça:
> Apparently you're using the default and buggy BufferedTransport...
> Have you try using TFramedTransport?
> you can have a look on the tests for an example:
> https://github.com/apache/thrift/tree/master/test/nodejs

That was the "problem". I switched in cpp and in the node code to Framed
transport ... and it works :D.

I searched the error for days by now, and you found the solution in 9
minutes. Thanks a lot and I owe you now a box of german beer ;).

Best wishes and many thanks

Wilm

Re: Newbie Question: getting thrift-service running (c++/nodejs)

Posted by Henrique Mendonça <he...@apache.org>.
Hi Wilm,

Apparently you're using the default and buggy BufferedTransport...
Have you try using TFramedTransport?
you can have a look on the tests for an example:
https://github.com/apache/thrift/tree/master/test/nodejs

Best,
Henrique


On 7 August 2013 13:43, Wilm Schumacher <wi...@cawoom.com> wrote:

> Hi,
>
> I'm new to thrift, and I have a little trouble getting everything running.
>
> At first the requirement: I want to get a c++-thrift-server running and
> call it by a node.js client.
>
> For that purpose I designed this "service":
>
> ## test.thrift ##
> namespace cpp test
>
> struct Message2Server {
>         1: string message
> }
>
> struct Message2Client {
>         1: string message
> }
>
> service test {
>   Message2Client ping( 1:Message2Server message )
> }
> ##################
>
> where I uses the two structs "Message2..." to simulate different more
> complicated in- and outputs, but here it actually only swaps strings for
> the purpose of testing.
>
> The client.cpp, server.cpp, client.js and server.js are found here (with
> the thrift file is included and where thrift is already run)
> https://lserv.uni-jena.de/upload-data/5202322b44bd7/test.zip
>
> I only swap a Message2Server and a Message2Client. With a "ping"-"pong"
>
> When I run the cpp-server and call it by the cpp-client everything is
> fine. I get my "ping"-"pong".
>
> But: when I run the node-server and call it with the node-client I get
> my "ping". However ... the "pong" won't arrive. I get a "ping failed:
> unknown result". Obviously the object I send is wrong. But what do I wrong?
>
> If I run the node-server and call it with the cpp-client I get an error
> from the server,
> "read(4) failed - not enough data"
> and from the client
> "ERROR: No more data to read."
>
> If I run the cpp-server and call it with the node-client I get an error
> from the server nothing happens. It seems that both sides wait for
> input. And if I kill the client, I get the error from the server
> "Thrift: Wed Aug  7 13:28:37 2013 TSimpleServer client died: No more
> data to read." (of course)
>
> Obviously I do something wrong. And I think it is on the "node"-side of
> the code. Unfortunately the official documentation for "thrift-node" is
> not too extensive and I didn't found any help, thus I wrote this message.
>
> If my question is already answered, or if I should read some
> documentation, I would be very happy for any hints.
>
> Thanks for reading and best wishes
>
> Wilm
>