Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yar在OS X上执行失败,但是Linux上执行正常[已解决,是php开启--with-debug编译参数的问题] #46

Closed
vimac opened this issue May 18, 2015 · 6 comments

Comments

@vimac
Copy link

vimac commented May 18, 2015

在Mac上客户端报的错误是:

server responsed non-200 code '500'

error_log中的服务器端的错误是

PHP Fatal error:  Yar_Server::handle():  in /Users/mac/work/yarTest/server.php on line 16

用的代码就是官网提供的例子,如下:

<?php

ini_set("display_errors", "Off");

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

    /**
     * generated
     * @return
     */
    protected function client_can_not_see() {
    }
}


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

调用代码

<?php
$x = new Yar_Client('http://target_server/test.php');
try {
    $param = 'hello';
    $ret = $x->doApi($param);
    var_dump($ret);
} catch (Exception $e ) {
    echo $e->getMessage();
}

Mac上测试了1.2.3和1.2.4
Linux上面只测试了1.2.3
PHP是homebrew-php的php56

@vimac
Copy link
Author

vimac commented May 18, 2015

#27 仔细看了一下就是这个问题,我在反复尝试中(牵扯到重启php-fpm)也偶尔出现过 #27 描述的问题

@vimac
Copy link
Author

vimac commented May 19, 2015

发现是php编译的时候带上了--with-debug的参数导致了这个问题,如果是干净的安装,就没有这个问题了

另外在问题还存在时,我通过土办法在yar_server.c里面插了大量的DEBUG_S代码,然后发现出现问题的似乎是php_yar_server_handle对于raw_data和payload的处理上,那里payload赋值之后用DEBUG_S打印出来的值是乱码(我看源码上下文似乎应该打印出来的是JSON, PHP, MSGPACK的三个值吧)
但能力有限,暂时不清楚怎么继续进一步了

@vimac vimac changed the title Yar在OS X上执行失败,但是Linux上执行正常 Yar在OS X上执行失败,但是Linux上执行正常[已解决,是php开启--with-debug编译参数的问题] May 19, 2015
@laruence
Copy link
Owner

你是否打开了display_errors?

@vimac
Copy link
Author

vimac commented May 19, 2015

反复确认是关闭的
不过我现在没有带 --with-debug 的php在使用,暂时没有问题
只出现在带--with-debug 编译参数的php上

@freedomlizhigang
Copy link

php7 打开 display_errors 确实会连接不上 不明原因

@laruence
Copy link
Owner

dispaly_errors你有了任何的错误就会直接输出, 从而破坏了yar协议的传输格式.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants