laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
https://reverb.laravel.com
MIT License
1.16k stars 97 forks source link

Maximum execution time #265

Closed abdulbasit-dev closed 2 weeks ago

abdulbasit-dev commented 1 month ago

Reverb Version

1.0

Laravel Version

11.9

PHP Version

8.2

Description

While running the reverb in localhost after same minitus i get this error and the reverb connection will be closed. i also increased the execution time in AppServiceProvider

    // max execution time
    ini_set('max_execution_time', 300);
Maximum execution time of 300 seconds exceeded

  at vendor/react/event-loop/src/StreamSelectLoop.php:291
    287▕                 }
    288▕             }
    289▕ 
    290▕             /** @var ?callable $previous */
  ➜ 291▕             $previous = \set_error_handler(function ($errno, $errstr) use (&$previous) {
    292▕                 // suppress warnings that occur when `stream_select()` is interrupted by a signal
    293▕                 // PHP defines `EINTR` through `ext-sockets` or `ext-pcntl`, otherwise use common default (Linux & Mac)
    294▕                 $eintr = \defined('SOCKET_EINTR') ? \SOCKET_EINTR : (\defined('PCNTL_EINTR') ? \PCNTL_EINTR : 4);
    295▕                 if ($errno === \E_WARNING && \strpos($errstr, '[' . $eintr .']: ') !== false) {

image

Steps To Reproduce

while running this in the localhost

php artisan reverb:start

crynobone commented 1 month ago

Can you try the following configuration for reverb.php:

    'servers' => [

        'reverb' => [
            'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
            'port' => env('REVERB_SERVER_PORT', 8080),
            'hostname' => env('REVERB_HOST'),
            'options' => [
                'tls' => [],
+.             'timeout' => false,
            ],
abdulbasit-dev commented 1 month ago

@crynobone still same issue image

RobertBoes commented 1 month ago

Using ini_set('max_execution_time', 300); in your AppServiceProvider would set the max execution time to 300 seconds, so yes, the Reverb server will be stopped after 300 seconds.

Reverb is a long-running process, since it's ran through the CLI it would have a timeout of -1 by default, which allows it to run until stopped. Your PHP ini config probably has a max timeout set, so the script will stop after that time. In order for it to work properly you'd need to set the timeout to -1, ideally with different config files, one for the web server and one for the CLI scripts.

abdulbasit-dev commented 1 month ago

@RobertBoes thanks 🙏 image

by moving the ini_set('max_execution_time', 300); to production it solve the problem, and reverb is not stopped