You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Anupam Singh <an...@shop2020.in> on 2012/06/27 13:13:09 UTC
Thrift — Socket closed prematurely
I am using thrift client-server communication for a webapp. I have got two
services A and B Service A is in *Java* and runs *TthreadPoolServer* Service
B is *python* and runs *TThreadedServer*
Problem occurs when:
1. Webapp calls Service A.
2. Service A in turn calls few other services and then at the end calls
Service B.
3. Service B in turn calls Service A for some other data.
4. While Service B is still doing work, exception comes midway in *A-->B
thrift call* with following StackTrace.
org.apache.thrift.transport.TTransportException: java.net.SocketException:
Socket closed at
org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) at
org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:129)
at
org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) at
org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at
org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at
org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69) at
in.shop2020.model.v1.user.PromotionService$Client.recv_applyCoupon(PromotionService.java:235)
Some points regarding this problem that I have noted are following:
1. This issue occurs on one server and not on other.
2. All sockets are created successfully as Service B actually does all
work that it is supposed to do. In fact it even calls service A again to
get some data.
3. Time between service B call and exception is generally very less. It
almost always stays less than 100 ms.
4. I have tried increasing timeouts for all sockets(Service A client,
Service A server, Service B client, Service B server).
5. I have also tried increasing number of workerthreads in
TthreadPoolServer in Service A
6. I have also tried setting soLinger true for TScocket
7. I saw that sockets were getting created for call from Service A to
Service B.
8. The positioning of this method call is irrelevant for the problem in
Service A method.
9. If I remove the call to Service A from Service B I don't get the
exception
AW: Thrift - Socket closed prematurely
Posted by Roger Meier <ro...@bufferoverflow.ch>.
Did you try latest Apache Thrift version?
Do you have a test case for thrift/test/test.sh ?
;-r
> -----Ursprüngliche Nachricht-----
> Von: Anupam Singh [mailto:anupam.singh@shop2020.in]
> Gesendet: Mittwoch, 27. Juni 2012 13:13
> An: thrift-user@incubator.apache.org
> Betreff: Thrift Socket closed prematurely
>
> I am using thrift client-server communication for a webapp. I have got two
> services A and B Service A is in *Java* and runs *TthreadPoolServer*
Service
> B is *python* and runs *TThreadedServer*
>
> Problem occurs when:
>
> 1. Webapp calls Service A.
> 2. Service A in turn calls few other services and then at the end calls
> Service B.
> 3. Service B in turn calls Service A for some other data.
> 4. While Service B is still doing work, exception comes midway in
*A-->B
> thrift call* with following StackTrace.
>
> org.apache.thrift.transport.TTransportException: java.net.SocketException:
> Socket closed at
> org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.ja
> va:132)
> at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) at
> org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport
> .java:129)
> at
> org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:
> 101)
> at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) at
>
org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
> at
>
org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
> at
> org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtoc
> ol.java:204)
> at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69) at
> in.shop2020.model.v1.user.PromotionService$Client.recv_applyCoupon(Pro
> motionService.java:235)
>
> Some points regarding this problem that I have noted are following:
>
> 1. This issue occurs on one server and not on other.
> 2. All sockets are created successfully as Service B actually does all
> work that it is supposed to do. In fact it even calls service A again
to
> get some data.
> 3. Time between service B call and exception is generally very less. It
> almost always stays less than 100 ms.
> 4. I have tried increasing timeouts for all sockets(Service A client,
> Service A server, Service B client, Service B server).
> 5. I have also tried increasing number of workerthreads in
> TthreadPoolServer in Service A
> 6. I have also tried setting soLinger true for TScocket
> 7. I saw that sockets were getting created for call from Service A to
> Service B.
> 8. The positioning of this method call is irrelevant for the problem in
> Service A method.
> 9. If I remove the call to Service A from Service B I don't get the
> exception