Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-25.2.0 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Server->heartbeat(bool $ifCloseConnection = true): bool|array
Whether to close any detected timed out connections based on the server configuration options that are set.
If successful, an array of closed connection fds are returned, otherwise if something went wrong or no connections are closed/found false is returned instead.
This method is difference from the heartbeat_check_interval server configuration, which is passive. The heartbeat method actively checks all connections to see if they have exceeded the agreed heartbeat timeout set within the server configuration options.
By default, calling this method will close any idle connections but you can disable this by passing false.
<?php
$closeFdArrary = $server->heartbeat();
var_dump($closeFdArrary);