You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by JKnight JKnight <be...@gmail.com> on 2010/11/11 04:32:43 UTC
TSocket: Could not connect to ...(Connection timed out [110])
Dear all,
I use Java to implement Thrift server and use PHP for client.
Here is the server code:
TNonblockingServerSocket socket = new TNonblockingServerSocket(
listenPort);
THsHaServer.Options options = new THsHaServer.Options();
options.minWorkerThreads = 64;
TServer serverEngine = new THsHaServer(processor, socket, options);
Here is client code:
$this->socket = new TSocket($this->_host, $this->_port);
$this->socket->setSendTimeout($this->_sendTimeOut);
$this->socket->setRecvTimeout($this->_recvTimeOut);
$this->transport = new TFramedTransport($this->socket);
$this->protocol = new TBinaryProtocol($this->transport);
$this->client = new AppServiceClient($this->protocol);
function openTransport(){
if(!$this->transport->IsOpen()){
$this->transport->open();
}
}
function closeTransport(){
if($this->transport->IsOpen()){
$this->transport->close();
}
}
public function get_app($id)
{
try
{
$this->openTransport();
$data = $this->client->get_app($id);
}
catch (Exception $e)
{
$this->logs($e->getMessage());
$this->closeTransport();
return array ();
}
return $data;
}
private function logs($log){
$datetime = (float) array_sum(explode(' ',microtime()));
file_put_contents("logs/data.txt", date('Y-m-d
H:i:s')."\t".$datetime."\t".$log."\n", FILE_APPEND);
}
When I trace PHP log, I found the error:
TSocket: Could not connect to ... (Connection timed out [110])
This error occurs once per second.
No error in Java server.
Could you help me to fix this problem?
Thank a lot for support.
--
Best regards,
JKnight