Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
pecl install openswoole-22.0.0
<?php Swoole\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
<?php $closeFdArrary = $server->heartbeat(); var_dump($closeFdArrary);