根據鳥哥部落格上Yar的介紹,書寫樣本時,報Yar_Client_Protocol_Exception錯誤,Google和Baidu都沒有查到解決辦法,各位大俠有沒有知道的呢?
yarServer.php
class API { public function hello ($param = '') { return $param; } protected function hello2 () { }}$service = new Yar_Server(new API());$service->handle();
yarClient.php
SetOpt(YAR_OPT_CONNECT_TIMEOUT, 1000);//Set packager to JSON$client->SetOpt(YAR_OPT_PACKAGER, "json");$result = $client->hello('zhangsan');
錯誤詳情
Warning: [Debug Yar_Client 15:48:0.982003]: 2204859703: call api 'hello' at (r)'http://yar.demo.com/yarServer.php' with '1' parameters in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10Warning: [Debug Yar_Client 15:48:0.982082]: 2204859703: pack request by 'JSON', result len '53', content: '{"i":2204859703,"m":"hello","p":' in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10Fatal error: Uncaught exception 'Yar_Client_Protocol_Exception' with message 'malformed response header 'Warning: [Debug Yar_Server 15:4'' in /home/liuruntao/YarRPC-Demo/public/yarClient.php:10Stack trace:#0 /home/liuruntao/YarRPC-Demo/public/yarClient.php(10): Yar_Client->__call('hello', Array)#1 /home/liuruntao/YarRPC-Demo/public/yarClient.php(10): Yar_Client->hello('zhangsan')#2 {main} thrown in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10
回複內容:
根據鳥哥部落格上Yar的介紹,書寫樣本時,報Yar_Client_Protocol_Exception錯誤,Google和Baidu都沒有查到解決辦法,各位大俠有沒有知道的呢?
yarServer.php
class API { public function hello ($param = '') { return $param; } protected function hello2 () { }}$service = new Yar_Server(new API());$service->handle();
yarClient.php
SetOpt(YAR_OPT_CONNECT_TIMEOUT, 1000);//Set packager to JSON$client->SetOpt(YAR_OPT_PACKAGER, "json");$result = $client->hello('zhangsan');
錯誤詳情
Warning: [Debug Yar_Client 15:48:0.982003]: 2204859703: call api 'hello' at (r)'http://yar.demo.com/yarServer.php' with '1' parameters in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10Warning: [Debug Yar_Client 15:48:0.982082]: 2204859703: pack request by 'JSON', result len '53', content: '{"i":2204859703,"m":"hello","p":' in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10Fatal error: Uncaught exception 'Yar_Client_Protocol_Exception' with message 'malformed response header 'Warning: [Debug Yar_Server 15:4'' in /home/liuruntao/YarRPC-Demo/public/yarClient.php:10Stack trace:#0 /home/liuruntao/YarRPC-Demo/public/yarClient.php(10): Yar_Client->__call('hello', Array)#1 /home/liuruntao/YarRPC-Demo/public/yarClient.php(10): Yar_Client->hello('zhangsan')#2 {main} thrown in /home/liuruntao/YarRPC-Demo/public/yarClient.php on line 10
報錯的原因找到了,只要把yar的debug功能關掉就可以!
vim php.iniyar.debug=0 ;或者注釋掉
這樣是可以解決上述問題,樓主是否知道為啥會報這個warning,為啥呢?