We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
服務端: Swoole Hprose 客戶端: PHP Hprose
在客戶端創了個協程,協程中使用yield等待返回異步方法結果。 請問為什麼結果會是response read error? 但是,把服務端及客戶端由tcp改為http,就能正常操作。
\Hprose\Future\co(function() { $rpc = new \Hprose\Socket\Client("tcp://localhost:2099", true); $session = $rpc->session; try { $result1 = yield $session->test1(); $result2 = yield $session->test2($result1); $session->testLog($result2); }catch (\Exception $e) { $session->testLog($e->getMessage()); $session->testLog($e->getTraceAsString()); } }
Result:
string(19) "response read error" string(885) "#0 D:\AppServ\www\test-hprose-laravel-client\vendor\hprose\hprose\src\Hprose\Socket\HalfDuplexTransporter.php(42): Hprose\Socket\Transporter->getLastError('response read e...') #1 D:\AppServ\www\test-hprose-laravel-client\vendor\hprose\hprose\src\Hprose\Socket\Transporter.php(136): Hprose\Socket\HalfDuplexTransporter->asyncReadError(Object(stdClass), Resource id #235, 0) #2 D:\AppServ\www\test-hprose-laravel-client\vendor\hprose\hprose\src\Hprose\Socket\Transporter.php(275): Hprose\Socket\Transporter->asyncRead(Resource id #235, Object(stdClass)) #3 D:\AppServ\www\test-hprose-laravel-client\vendor\hprose\hprose\src\Hprose\Socket\Client.php(107): Hprose\Socket\Transporter->loop() #4 D:\AppServ\www\test-hprose-laravel-client\vendor\hprose\hprose\src\Hprose\Socket\Client.php(44): Hprose\Socket\Client->loop() #5 [internal function]: Hprose\Socket\Client->__destruct() #6 {main}"
服務端就是簡單一個swoole的程序:
<?php require_once "vendor/autoload.php"; use Hprose\Swoole\Server; function session_testLog($text) { var_dump($text); } function session_test1() { return 'abc'; } function session_test2($text) { return 'Input text: ' . $text; } $server = new Server('tcp://0.0.0.0:2099'); $server->addFunction('session_getSession'); $server->addFunction('session_testLog'); $server->addFunction('session_test1'); $server->addFunction('session_test2'); $server->start();
The text was updated successfully, but these errors were encountered:
我也不清楚。目前的 TCP 实现过于复杂,我也不知道问题在哪儿。新版本会简化客户端实现,到时候也许这个问题就没了。
Sorry, something went wrong.
No branches or pull requests
服務端: Swoole Hprose
客戶端: PHP Hprose
在客戶端創了個協程,協程中使用yield等待返回異步方法結果。
請問為什麼結果會是response read error?
但是,把服務端及客戶端由tcp改為http,就能正常操作。
Result:
服務端就是簡單一個swoole的程序:
The text was updated successfully, but these errors were encountered: