Looks pretty standard. I'd be interested to see where the client is
hanging. It doesn't seem likely, but maybe it is during the send?
You could try setting a send timeout.
--David
Curtis Spencer wrote:
> Hi,
>
> First message to the thrift list. Thanks for releasing such a great
> technology.
>
> I have been mainly using the C++ versions of client and server, but I
> have been rarely encountering a problem that I don't really have much
> data to help discern.
> I wanted to see if this is something others had encountered and
> whether or not I am doing something silly.
>
> The problem I see is that my application servers (which are the
> clients to a thrift service) periodically hang. I can restart the
> thrift service and the application servers (without restart) are happy
> again.
>
> The only output I see is at the thrift service level and what I get is this:
>
> TServerTransport died on accept: Called write on non-open socket
> Thrift: Wed May 6 09:30:07 2009 TSocket::write() send() <Host: Port:
> 0>Broken pipe
> TSimpleServer client died: write() send(): Broken pipe
> TServerTransport died on accept: Called write on non-open socket
> Thrift: Wed May 6 09:30:07 2009 TSocket::write() send() <Host: Port:
> 0>Broken pipe
> TSimpleServer client died: write() send(): Broken pipe
> TServerTransport died on accept: Called write on non-open socket
> Thrift: Wed May 6 09:30:07 2009 TSocket::write() send() <Host: Port:
> 0>Broken pipe
> TSimpleServer client died: write() send(): Broken pipe
> TServerTransport died on accept: Called write on non-open socket
> Thrift: Wed May 6 09:30:07 2009 TSocket::write() send() <Host: Port:
> 0>Broken pipe
> TSimpleServer client died: write() send(): Broken pipe
> TServerTransport died on accept: Called write on non-open socket
> Thrift: Wed May 6 09:30:07 2009 TSocket::write() send() <Host: Port:
> 0>Broken pipe
> TSimpleServer client died: write() send(): Broken pipe
> TServerTransport died on accept: Called write on non-open socket
> TSimpleServer client died: No more data to read.
>
> For the next time I see it happen, I now have them both running with
> debug symbols so i will attach to them with gdb and see exactly where
> they are at, so I can add more information to this thread.
>
> As for the client/server code, my server looks pretty cookie cutter:
>
> int main(int argc, char **argv) {
> int port = 9092;
> shared_ptr<MyHandler> handler(new MyHandler());
> shared_ptr<TProcessor> processor(new MyProcessor(handler));
> shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
> shared_ptr<TTransportFactory> transportFactory(new
> TBufferedTransportFactory());
> shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
>
> TSimpleServer server(processor, serverTransport, transportFactory,
> protocolFactory);
> server.serve();
> return 0;
> }
>
> My client that does the connection is:
>
> shared_ptr<TSocket> socket(new TSocket(host_name,port)));
> socket->setConnTimeout(THRIFT_TIMEOUT); // Which Equals 10000
> socket->setRecvTimeout(THRIFT_TIMEOUT);
> shared_ptr<TTransport> transport(new TBufferedTransport(socket));
> shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
> MyClient client(protocol);
> try {
> transport->open();
> client.mycall(results);
> transport->close();
> } catch (TException &tx) {
> cerr << "Caught Exception" << endl;
> }
>
>
> Anything look fishy there?
>
> Thanks in advance,
> Curtis