-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server-reload() does not terminate Swoole Timers, gracefully #361
Comments
Here is my GitHub Repo The branch to checkout is named as timer_issue_branch you can use composer install to install dependencies. Mentioned below is the .env file:
cd to swoole-serv folder, and then run the command below
|
In the screenshot below, the
Here is the video link that captures my screen and i explain the issue. About Code Flow / Organization:
On line 36 of service_creation_params.php, the code evaluates serverMode to SWOOLE_PROCESS when we do not specifically mention SWOOLE_BASE on command-line as second argument. Swoole's configurations are defined in The class defined in
Please, let me know if you need further information to reproduce the bug. Understanding of The Abnormal Behaviour
Question-2) The Timer's callback continues to execute the |
I solved the issue as below. Inside Timer's callback, instead of using i use this ... In other words, Timer's whole callback below changes from ...
To ...
So, now when i reload the code, the Timers are cleared from inside the callback. Whereas, when code is not reloaded the timer is closed from inside the (callback for) onClose event. |
Terminology used in Code below:
I create this Swoole's timer from inside onMessage Event and in the same onMEssage, i also calll reload(), as below:
I use WebSocket's push() function from inside Swoole's Timer's callback which pushes data, and is defined as below:
Other related Code:
Below are my Before/After Reload events:
As you see i tried clearing timers here but that also did not help so i commented the code.
No PHP Warning from WebSocketServer->push()
Inside Timers, i use push() which continues to send data to an $fd, even after Timer has been cleared. This issue occurs only if i cause
$webSocketServer->reload()
to be executed from other terminal.So i get this PHP Warning, repeatedly:
PHP Warning: Swoole\WebSocket\Server::push(): session#1 does not exists in /var/www/html/swoole-serv/sw_service.php on line 425
PHP Warning: Swoole\WebSocket\Server::push(): session#1 does not exists in /var/www/html/swoole-serv/sw_service.php on line 425
PHP Warning: Swoole\WebSocket\Server::push(): session#1 does not exists in /var/www/html/swoole-serv/sw_service.php on line 425
PHP Warning: Swoole\WebSocket\Server::push(): session#1 does not exists in /var/www/html/swoole-serv/sw_service.php on line 425
php --ri openswoole
)?uname -a
&php -v
&gcc -v
) ?You can also try the following OpenSwoole support channels:
The text was updated successfully, but these errors were encountered: