Join 4,000+ others and never miss out on new tips, tutorials, and more.
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
In seconds, the timeout of the request, 1.5 means 1.5 seconds. See the timeout guide link below.
Returns a client
OpenSwoole\Http2\Response object when successful and
false when not, check
$client->errCode for more details upon an error.
Receive a response from the remote host.
When using this method, while waiting for IO OpenSwoole will switch coroutines so resources are not wasted and return upon a response or failure.
The built in HTTP clients have a timeout option, allowing you to wait for a response, the timeout can be set in a few different ways, refer to the timeout guide for more information. However, the
$timeout parameter will work in most cases.
Response HTTP/2 Object
This method returns a
OpenSwoole\Http2\Response object which is a class with no methods, only public class properties which you can access, see the response object documentation for more details and what it contains. This object is only returned on a successful response. Check
$client->errCode if you receive
Check the main Quick Start Examples to see how the
recv() method is used in its full context.