laruence/yar

客户端调用服务端,500错误,请看日志

Closed this issue · 3 comments

php7.3
yar 2.1.2
image

服务端代码

class RpcController
{
//直接输出客户端传递的参数
    public function test($a)
    {
        return $a;
    }
}
$service = new Yar_Server(new \RpcController());
$service->handle();

客户端调用代码

public function rpcAction()
    {
        $client = new yar_client("http://yartest.com/rpc/");
        var_dump($client->test("8"));
    }

错误日志

<br />
<b>Warning</b>:  [Debug Yar_Client 18:23:56.458994]: 2709288286: call api 'test' at (r)'http://yartest.com/rpc/' with '1' parameters in <b>/data/Controllers/TestController.php</b> on line <b>62</b><br />
<br />

<b>Warning</b>:  [Debug Yar_Client 18:23:56.459018]: 2709288286: pack request by 'PHP', result len '82', content: 'a:3:{s:1:"i";i:2709288286;s:1:"m' in <b>/data/Controllers/TestController.php</b> on line <b>62</b><br />

{"code":"-1","msg":"\nError Code: 16\nserver responsed non-200 code '500'\n#0 \/data\/ucenter\/Controllers\/TestController.php(62): Yar_Client->__call('test', Array)\n#1 [internal function]: TestController->rpcAction('App\\\\Con...', 'test', 'rpc')\n#2 [internal function]: Phalcon\\Dispatcher->callActionMethod(Object(TestController), 'rpcAction', Array)\n#3 [internal function]: Phalcon\\Dispatcher->dispatch()\n#4 

\/data\app\/Sdks\/Core\/System\/Application\/CustomApplication.php(28): Phalcon\\Mvc\\Application->handle()\n#5 \/data\app\/bootstrap\/bootstrap.php(143): App\\Sdks\\Core\\System\\Application\\CustomApplication->run()\n#6 \/data\\/public\/ucenter\/index.php(4): require('\/data\/web\/...')\n#7 {main}\narray (\n  '_url' => '\/test\/rpc',\n)\n","body":{}}

客户端/服务端 代码在同一个项目中.

http://yartest.com
只是本机自定义的一个域名 通过添加hosts访问

image
这个使用的是默认的方式

你把服务端的错误日志打开,服务端出错了