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
你好,我在webman项目中引入了你的http库,然后发现http并发请求无法执行,或者是执行后callback没有执行。当php进程结束时,console才输出了所有的callback内容;
然后我去阅读源代码,我发现在 并发异步请求后,你是不是少了2行代码?我现在将它标记出来,你可以检测看是否缺失;
这是你的demo
$promises = [ Http::getAsync('http://easyhttp.yzh52521.cn/api/sleep3.json'), Http::getAsync('http1://easyhttp.yzh52521.cn/api/sleep1.json', ['name' => 'yzh52521']), Http::postAsync('http://easyhttp.yzh52521.cn/api/sleep2.json', ['name' => 'yzh52521']), ]; Http::concurrency(3)->multiAsync($promises, function (Response $response, $index) { echo "发起第 $index 个异步请求,请求时长:" . $response->json()->second . '秒' . PHP_EOL; }, function (RequestException $e, $index) { echo "发起第 $index 个请求失败,失败原因:" . $e->getMessage() . PHP_EOL; });
我补充后的demo用法:
$promises = [ Http::getAsync('http://easyhttp.yzh52521.cn/api/sleep3.json'), Http::getAsync('http1://easyhttp.yzh52521.cn/api/sleep1.json', ['name' => 'yzh52521']), Http::postAsync('http://easyhttp.yzh52521.cn/api/sleep2.json', ['name' => 'yzh52521']), ]; $pool = Http::concurrency(3)->multiAsync($promises, function (Response $response, $index) { echo "发起第 $index 个异步请求,请求时长:" . $response->json()->second . '秒' . PHP_EOL; }, function (RequestException $e, $index) { echo "发起第 $index 个请求失败,失败原因:" . $e->getMessage() . PHP_EOL; }); // 等待请求完成 $promise = $pool->promise(); // 强制结束请求 $promise->wait();
The text was updated successfully, but these errors were encountered:
感谢反馈
Sorry, something went wrong.
@yzh52521 然后同时我也发现了,并发请求并不是真正意义上的并发。他不是一瞬间所有请求都打出,还是有顺序的请求; workerman-http 库是真做到异步请求,豪无阻塞的那种
No branches or pull requests
你好,我在webman项目中引入了你的http库,然后发现http并发请求无法执行,或者是执行后callback没有执行。当php进程结束时,console才输出了所有的callback内容;
然后我去阅读源代码,我发现在 并发异步请求后,你是不是少了2行代码?我现在将它标记出来,你可以检测看是否缺失;
这是你的demo
我补充后的demo用法:
The text was updated successfully, but these errors were encountered: