mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-08 08:59:19 +00:00
Add reconnection delay to prevent high CPU usage when server is unavailable. (#7736)
When the websocket server is unavailable the connection tries to reconnect too fast causing a high CPU usage. Adding a check for the connection status and sleeping when it is not yet connected after a re-connect attempt prevents the high CPU usage. Fixed the method signature in create_filter_chain_for to exactly match that of the parent to avoid potential PHP warnings or errors.
This commit is contained in:
@@ -178,9 +178,9 @@ class active_conferences_service extends base_websocket_system_service implement
|
||||
*
|
||||
* @param subscriber $subscriber
|
||||
*
|
||||
* @return filter
|
||||
* @return filter|null
|
||||
*/
|
||||
public static function create_filter_chain_for(subscriber $subscriber): filter {
|
||||
public static function create_filter_chain_for(subscriber $subscriber): ?filter {
|
||||
// Domain filtering for conferences
|
||||
if ($subscriber->has_permission('conference_active_view')) {
|
||||
return filter_chain::and_link([
|
||||
|
||||
@@ -167,6 +167,11 @@ abstract class base_websocket_system_service extends service implements websocke
|
||||
if (!$suppress_ws_message) $this->error("Unable to connect to websocket server.");
|
||||
$suppress_ws_message = true;
|
||||
}
|
||||
if (!$this->ws_client->is_connected()) {
|
||||
// Sleep for a bit before trying to reconnect to prevent flooding the logs with connection errors
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->ws_client !== null && $this->ws_client->is_connected()) {
|
||||
|
||||
Reference in New Issue
Block a user