Hi, I am from Chinese, I firstly use thrift to project. I encountered one 
problem, not know how to solve.
when thrift client connect thrift server for a long time, client throw 
exception "read time out". when throw "read time out" exception, program close 
this socket, blow my code:
private boolean isBroken = true;


private TSocket tsocket = null;


protected void openConnect(){
try {
tsocket = new TSocket(this.host, this.port);
if(this.timeout > 0){
tsocket.setTimeout(this.timeout);
}
TTransport transport = new TFramedTransport(tsocket);
TProtocol protocol = new TCompactProtocol(transport);
client = new Spout.Client(protocol);
transport.open();
} catch (TTransportException e) {
logger.error(getErrorMessage(),e);
isBroken =false;
}


protected void destoryConnect(){
if(null != tsocket || !isBroken){
tsocket.close();
tsocket = null;
}
}
public boolean timingPhotograph(String list_seq, String list_vid,
String channel, Map<String, String> protocolmap)  {
// TODO Auto-generated method stub
try {
return this.client.timingPhotograph(list_seq, list_vid, channel, protocolmap);
} catch (TException e) {
logger.error(getErrorMessage() + " timingPhotograph", e);
isBroken = false;
return false;
}
}


as a result : when client close socket,server socket is "CLOSE_WAIT" state, how 
to fix this.

Reply via email to