Coder Social home page Coder Social logo

Comments (14)

laruence avatar laruence commented on May 19, 2024

你先打开 yar.debug 看看是否请求正常发送, 看看是否server正常返回了.

from yar.

laruence avatar laruence commented on May 19, 2024

在php.ini中添加yar.debug=1, 然后观察error log, 记得要打开全部错误显示

from yar.

crazyant avatar crazyant commented on May 19, 2024

打开了,同步调用的服务器返回了
通过Yar_Concurrent_Client::call调用的没有返回。可能是连接超时。
同样的代码在centos上执行没有问题。

以下是代码:

server:

   class APIS {
    /**
     * the doc info will be generated automatically into service info page.
     * @params
     * @return
     */
    public function api($parameter, $option = "foo") {
        return $parameter.' haha '.$option;
    }
    public function method1() {
        return 'hellod';
    }

    protected function client_can_not_see() {
    }
}

$service = new Yar_Server(new APIS());
$service->handle();

client 调用:

   // 同步调用
    $client = new Yar_Client('http://loc.yarserver.com');

    $result = $client->api('ff');
    echo "Result Begin:\n";
    echo $result;
    echo "\nResult End\n\n";

// 异步调用
function callback1($retval, $callinfo) {
     echo 'callback';
}

function endCall() {
     echo "End\n";
}

function error_callback($type, $error, $callinfo) {
    echo "ErrorCallBack\n";
    var_dump($error);
}

Yar_Concurrent_Client::call("http://loc.yarserver.com/", "api", array('parad', 'fdsf'), 'callback1', 'error_callback',array(YAR_OPT_TIMEOUT=>10, YAR_OPT_CONNECT_TIMEOUT=>7));
Yar_Concurrent_Client::loop('endCall', 'error_callback');

日志:

PHP Warning:  [Debug Yar_Client 11:31:55.685710]: 489336978: call api 'api' at (r)'http://loc.yarserver.com' with '1' parameters in /opt/Workspace/yar_server/yartest.php on line 6
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

Warning: [Debug Yar_Client 11:31:55.685710]: 489336978: call api 'api' at (r)'http://loc.yarserver.com' with '1' parameters in /opt/Workspace/yar_server/yartest.php on line 6

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0004     231184   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

PHP Warning:  [Debug Yar_Client 11:31:55.8316866957937375174]: 489336978: pack request by 'PHP', result len '79', content: 'a:3:{s:1:"i";i:489336978;s:1:"m"' in /opt/Workspace/yar_server/yartest.php on line 6
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

Warning: [Debug Yar_Client 11:31:55.8316866957937375174]: 489336978: pack request by 'PHP', result len '79', content: 'a:3:{s:1:"i";i:489336978;s:1:"m"' in /opt/Workspace/yar_server/yartest.php on line 6

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0004     231184   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

PHP Warning:  [Debug Yar_Client 11:31:55.688648]: 489336978: server response content packaged by 'PHP', len '88', content 'a:4:{s:1:"i";i:489336978;s:1:"s"' in /opt/Workspace/yar_server/yartest.php on line 6
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

Warning: [Debug Yar_Client 11:31:55.688648]: 489336978: server response content packaged by 'PHP', len '88', content 'a:4:{s:1:"i";i:489336978;s:1:"s"' in /opt/Workspace/yar_server/yartest.php on line 6

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0004     231184   2. Yar_Client->api() /opt/Workspace/yar_server/yartest.php:6

Result Begin:
ff haha foo
Result End

PHP Warning:  [Debug Yar_Client 11:31:55.4295656282]: 1331227697: call api 'api' at (r)'http://loc.yarserver.com/' with '2' parameters in /opt/Workspace/yar_server/yartest.php on line 29
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

Warning: [Debug Yar_Client 11:31:55.4295656282]: 1331227697: call api 'api' at (r)'http://loc.yarserver.com/' with '2' parameters in /opt/Workspace/yar_server/yartest.php on line 29

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0037     233216   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

PHP Warning:  [Debug Yar_Client 11:31:55.689049]: 1331227697: pack request by 'PHP', result len '98', content: 'a:3:{s:1:"i";i:1331227697;s:1:"m' in /opt/Workspace/yar_server/yartest.php on line 29
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

Warning: [Debug Yar_Client 11:31:55.689049]: 1331227697: pack request by 'PHP', result len '98', content: 'a:3:{s:1:"i";i:1331227697;s:1:"m' in /opt/Workspace/yar_server/yartest.php on line 29

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0037     233216   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

End
PHP Warning:  Yar_Concurrent_Client::loop(): select timeout '5' seconds reached in /opt/Workspace/yar_server/yartest.php on line 29
PHP Stack trace:
PHP   1. {main}() /opt/Workspace/yar_server/yartest.php:0
PHP   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

Warning: Yar_Concurrent_Client::loop(): select timeout '5' seconds reached in /opt/Workspace/yar_server/yartest.php on line 29

Call Stack:
    0.0003     230040   1. {main}() /opt/Workspace/yar_server/yartest.php:0
    0.0037     233216   2. Yar_Concurrent_Client::loop() /opt/Workspace/yar_server/yartest.php:29

from yar.

laruence avatar laruence commented on May 19, 2024

Server没收到请求....

from yar.

crazyant avatar crazyant commented on May 19, 2024

我看了apache的访问日志,Yar_Client发出来的请求能到达,Yar_Concurrent_Client发请求根本就没到达,没有访问日志。
那应该是Yar_Concurrent_Client 的请求没成功发出去。

和mac系统有关系吗?

from yar.

laruence avatar laruence commented on May 19, 2024

哦, 你是mac啊, 可能和libcul有关, 你看看你的curl, 是不是这个版本:
cURL Information => 7.24.0

这个版本貌似有问题, 你升级一下, 换成7.32.0

from yar.

crazyant avatar crazyant commented on May 19, 2024

cURL Information => 7.30.0

不知道这个版本有没有问题。

from yar.

laruence avatar laruence commented on May 19, 2024

你能否试试换成7.32.0是否还有这个问题呢?

from yar.

crazyant avatar crazyant commented on May 19, 2024

我安装curl 7.32.0 并且明确地在安装php 的时候 --with-curl = 7.32.0所在目录之后。
php info 里cUrl Info 还是7.30.0.

不过,问题总算解决了,Yar_Concurrent_Client在mac上也能正常工作了,谢谢鸟哥!

from yar.

laruence avatar laruence commented on May 19, 2024

那就是Mac自带的有问题了....

from yar.

zxcvdavid avatar zxcvdavid commented on May 19, 2024

@crazyant 怎么解决的

from yar.

crazyant avatar crazyant commented on May 19, 2024

@zxcvdavid 的解决过程比较曲折。

  1. 用brew装了curl 7.32.0,目前直接 brew install curl 就是最新的。
  2. 手动编译安装了一个新的php,我装的php5.4.20,配置的时候 --with-apxs=/usr/sbin/apxs --with-curl=/usr/local/Cellar/curl/7.32.0/
  3. 安装成功后,系统的apache 加载的已经是新版本的php了,但有个问题,cUrl Information 还是老版本的。自命令行直接执行新版本phpinfo(), cUrl Information. 是7.32.0。折腾了许久之后终于找到了问题所在:httpd 加载 php 的时候,链接的libcurl的动态库来自 /usr/lib/libcurl.4.dylib,cli 模式下的来自 /usr/local/Cellar/curl/7.32.0/lib/libcurl.4.dylib,于是我 ln -s /usr/local/Cellar/curl/7.32.0/lib/libcurl.4.dylib /usr/lib/libcurl.4.dylib ,然后就好了。

from yar.

zxcvdavid avatar zxcvdavid commented on May 19, 2024

感谢分享, 赞一个!

from yar.

leephp avatar leephp commented on May 19, 2024

同样是mac 我是在执行loop的时候 fd 问题. 同样升级了 curl 然后 按照 crazyant的方法 链接了 新的lib文件. 这样就好了... 没用重新编译

from yar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.