phpinnacle / ridge

Pure asynchronous PHP implementation of the AMQP 0-9-1 protocol.
MIT License
50 stars 13 forks source link

Heartbeat doesn't work properly #26

Closed Volonda closed 2 years ago

Volonda commented 3 years ago

If some reason clent not able to send heartbeats (broken network etc) RabbitMQ server will close connection automaticly on his own side, but consumer still connected to server. Clinet is waiting of new messages but they will never come, because rabbitmq dosn`t have connection (and consumer) any more .

There is code in PHPinnacle\Ridge\Connection for send heartbeats, but no code for receive it and broke connection if heartbeats didn't came at proper time.

Mybe good idea to pass callback to heartbeat init function and call it if last read was too later.

https://github.com/phpinnacle/ridge/blob/b362ee698d0c1441c777d3496deff3bd614bf1c3/src/Connection.php#L163

public function heartbeat(int $interval, ?callable $connectionLost = null): void