gpt4 book ai didi

php - Apache 节俭 : client timeout issues

转载 作者:可可西里 更新时间:2023-10-31 22:14:36 26 4
gpt4 key购买 nike

我有一些带有 perl-server 和 php-client 的 Apache Thrift (v.0.6.1) 测试应用程序。

我无法解释的行为:如果我们使用无效参数调用服务器方法,我们会在服务器输出中看到错误,但 php-client 会无限期地等待响应。

这里是服务器的来源:

sub new {
my $classname = shift;
my $self = {};

return bless($self,$classname);
}

sub DateToTimestamp
{
my ($self, $date) = @_;
my $result = CommonAPI::DateToTimestamp($date);
return $result;
}

eval {
my $handler = new RPCHandler;
my $processor = new RPCPerformanceTest::RPCPerformanceTestProcessor($handler);
my $serversocket = new Thrift::ServerSocket(9091);
my $forkingserver = new Thrift::ForkingServer($processor, $serversocket);
print "Starting the server...\n";
$forkingserver->serve();
print "done.\n";
}; if ($@) {
if ($@ =~ m/TException/ and exists $@->{message}) {
my $message = $@->{message};
my $code = $@->{code};
my $out = $code . ':' . $message;
die $out;
} else {
die $@;
}
}

和客户:

try {

$socket = new TSocket($server_host, $server_port);

$transport = new TBufferedTransport($socket, 1024, 1024);
$protocol = new TBinaryProtocol($transport);

$client = new RPCPerformanceTestClient($protocol);
$transport->open();

$start = microtime(true);

$result = $client->DateToTimestamp('071/26/2011 01:23:45');

var_dump($result);

} catch (Exception $e) {
echo 'Exception: <b>' . $e->getMessage() . '</b>';
}

为什么会这样?是我的错吗?这是预期的行为吗?

最佳答案

Thrift PHP 库有点损坏。您需要手动设置超时例如

  $socket = new TSocket('host', 9095);
$socket->setSendTimeout(60000);
$socket->setRecvTimeout(60000)

关于php - Apache 节俭 : client timeout issues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6059071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com