A added timeout information

This commit is contained in:
a6a2f5842 2025-05-08 17:50:05 +02:00
parent 6f115a2a72
commit bbcb943daa
2 changed files with 10 additions and 14 deletions

View File

@ -470,10 +470,11 @@ class Handler implements MessageComponentInterface
) {
$pidcache_data = 'dedicated_data_'.$pid;
$pidcache_done = 'dedicated_data_'.$pid.'_done';
$pidcache_complete = 'dedicated_data_'.$pid.'_complete';
if (
cache()->has($pidcache_start)
&& ($diff = microtime(true) - ((int) cache()->get($pidcache_start))) > 20
&& ($diff = microtime(true) - ((int) cache()->get($pidcache_start))) > 60
) {
if (! $optional) {
$connection->send(json_encode([
@ -486,6 +487,7 @@ class Handler implements MessageComponentInterface
}
$this->channelManager->loop->cancelTimer($timer);
cache()->put($pidcache_complete, true, 360);
}
if (cache()->has($pidcache_done)) {

View File

@ -50,6 +50,13 @@ class MockConnection extends Connection implements \Ratchet\ConnectionInterface
public function send($data)
{
if(cache()->get('dedicated_data_'.$pid.'_complete')){
Log::error('[MockConnection] Send for pid: ' . getmypid() . ' which is already completed and does not check for new data', [
'data' => $data,
]);
return false;
}
Log::channel('websocket')->info('[MockConnection] Send for pid: ' . getmypid(), [
'data' => $data,
]);
@ -59,19 +66,6 @@ class MockConnection extends Connection implements \Ratchet\ConnectionInterface
cache()->put($key, $data, 60);
cache()->put($key . '_done', true, 60);
// ==== Alternative way without using cache
// if (is_string($data)) {
// $d = json_decode($data, true);
// \App\Events\TenantEvent::dispatch(
// optional(optional(tenant())->tenantable)->public_id,
// $d['event'],
// (is_array($d['data']))
// ? $d['data']
// : ['data' => $d['data']]
// );
// }
return $this;
}