windows 平台 报错 Yar_Client_Transport_Exception' with message 'curl exec failed 'Timeout was reached'
Closed this issue · 14 comments
BUG现象同:#15
环境:
windows7
php5.6.10/5.6.11 (nts x86)
nginx 1.9.2
cURL Information 7.42.1
msgpack 0.5.6
yar 1.2.3/1.2.4
错误为:
Yar_Client_Transport_Exception’ with message ‘curl exec failed ‘Timeout was reached’
配置了php.ini中yar.debug=1,可以看到:
Warning: [Debug Yar_Client 18:39:21.422666]: 575645727: call api ‘api’ at (r)’http://zftest/yar/service/TestServiceProvider.php‘ with ’1′ parameters in E:\workspace\test_project\unit_test\src\main\yar\client\TestConsumer.php on line 31
Warning: [Debug Yar_Client 18:39:21.422666]: 575645727: pack request by ‘PHP’, result len ’80′, content: ‘a:3:{s:1:”i”;i:575645727;s:1:”m”‘ in E:\workspace\test_project\unit_test\src\main\yar\client\TestConsumer.php on line 31
跟了一下nginx的access日志:
POST /yar/service/TestServiceProvider.php HTTP/1.1 499 0 4.992
第一部分,post请求,
第二部分:请求地址与协议,
第三部分:返回的http状态码
第四部分:消息体长度
第五部分:请求时长
就是返回超时啊
正常的CURL可以得到结果,并无超时啊
在 2015-07-19 10:55:36,"Xinchen Hui" notifications@github.com 写道:
就是返回超时啊
—
Reply to this email directly or view it on GitHub.
可能是你的超时时间设置太短了,单位是毫秒。
我也遇到相同的问题
$client->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 50000);
还是超时
不知道跟Server API CGI/FastCGI有没有关系 我用wamp环境试了下就可以了 Server API apache 2.0
2016/03/04 13:07:37 [error] 6292#7292: *1 FastCGI sent in stderr: "PHP Fatal error: Uncaught exception 'Yar_Client_Transport_Exception' with message 'curl exec failed 'Timeout was reached'' in E:\wnmp\www\test\cline.php:10
Stack trace:
#0 E:\wnmp\www\test\cline.php(10): Yar_Client->__call('get_all_provinc...', Array)
#1 E:\wnmp\www\test\cline.php(10): Yar_Client->get_all_provinces()
#2 {main}
thrown in E:\wnmp\www\test\cline.php on line 10" while reading response header from upstream, client: 127.0.0.1, server: www.shell.com, request: "GET /cline.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.shell.com"
@lidonghui-ht CONNECT是连接超时, 你可以试试YAR_OPT_TIMEOUT
我也遇到这个问题了
php version 5.6.20
yar version 1.23
使用的是 php -S localhost:8000 启动的web服务器
/server.php
<?php
class API {
/**
* the doc info will be generated automatically into service info page.
* @params
* @return
*/
public function api($parameter, $option = "foo")
{
return $parameter;
}
protected function client_can_not_see() {
}
}
$service = new Yar_Server(new API());
$service->handle();
?>
/client.php
<?php
$client = new Yar_Client("http://localhost:8000/server.php");
$client->SetOpt(YAR_OPT_CONNECT_TIMEOUT, 10000);
$client->SetOpt(YAR_OPT_TIMEOUT, 10000);
$result = $client->api("parameter");
echo $result;
?>
报错:
Fatal error: Uncaught exception 'Yar_Client_Transport_Exception' with message 'curl exec failed 'Timeout was reached'' in /usr/local/var/www/tmp/yar/client.php:4
Stack trace:
#0 /usr/local/var/www/tmp/yar/client.php(4): Yar_Client->__call('api', Array)
#1 /usr/local/var/www/tmp/yar/client.php(4): Yar_Client->api('parameter')
#2 {main} thrown in /usr/local/var/www/tmp/yar/client.php on line 4
文档能看,不过也报了一个错:
Warning: Missing argument 1 for API::api(), called in /usr/local/var/www/tmp/yar/server.php on line 17 and defined in /usr/local/var/www/tmp/yar/server.php on line 8
Notice: Undefined variable: parameter in /usr/local/var/www/tmp/yar/server.php on line 10
我也碰到这个问题,不知道怎么解。
环境:
window10,php 5.5.30,yar 1.2.5/1.2.4(nts x86),nginx1.9
win7环境下就是正常的,window10环境我在几台电脑上试了都报同样的错误。
这个是例子的问题 , api被认为是API类的构造函数了. 忽略就可以.. 或者把api改个名
感谢鸟哥的回复。
我是自己写的例子也是报 'Timeout was reached',window10环境报错,win7是正常的。
/service 本地配置域名http://test.s.com:
<?php
class Test
{
/**
* @param $a
* @param $b
* @return mixed
*/
public function add($a, $b)
{
return $a + $b;
}
}
$server = new Yar_Server(new Test);
$server->handle();
/client
<?php
$client = new Yar_Client("http://test.s.com");
$re = $client->add(1,2);
print_r($client);
print_r($re);
错误信息:
Warning: [Debug Yar_Client 17:49:31.24212]: 344976562: call api 'add' at (r)'http://test.s.com' with '2' parameters in D:\www\test\public\index.php on line 4
Warning: [Debug Yar_Client 17:49:31.24231]: 344976562: pack request by 'PHP', result len '82', content: 'a:3:{s:1:"i";i:344976562;s:1:"m"' in D:\www\test\public\index.php on line 4
Fatal error: Uncaught exception 'Yar_Client_Transport_Exception' with message 'curl exec failed 'Timeout was reached'' in D:\www\test\public\index.php:4 Stack trace: #0 D:\www\test\public\index.php(4): Yar_Client->__call('add', Array) #1 D:\www\test\public\index.php(4): Yar_Client->add(1, 2) #2 {main} thrown in D:\www\test\public\index.php on line 4
@fangzhoou 你是不是用了PHP built in server
php内置开发服务器不行,换成php-fpm可以
@hgkmail 忘记了,不知道,不关注这个问题了,改行了。。。