程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Ping using Guzzle Http php

发布于2023-05-25 21:37     阅读(640)     评论(0)     点赞(11)     收藏(0)


I want to use guzzle http for ping. I dont care about the response. Just request is enough. No need of response. After request the code need to exits. Dont wait for response.

I tried to do with async.

<?php
require_once "vendor/autoload.php";

$client = new GuzzleHttp\Client();

$promise1 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async1');

$promise2 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async2');

$promise3 = $client->requestAsync('GET', 'http://localhost/test/?id=from_async3');

$promise1->then(function (ResponseInterface $response) {

});

$promise2->then(function (ResponseInterface $response) {

});

$promise3->then(function (ResponseInterface $response) {

});
$promise1->wait();

$promise2->wait();

$promise3->wait();

But still this script waits for all response to come back.

How to get the script work without waiting for response? Any thoughts?


解决方案


暂无回答



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.phpheidong.com/blog/article/546156/fb5593a80d32a52a333b/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

11 0
收藏该文
已收藏

评论内容:(最多支持255个字符)