jakubkulhan / bunny

Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library
MIT License
698 stars 101 forks source link

Change state to error when ClientException is throw #115

Closed frankvanhest closed 3 months ago

frankvanhest commented 3 years ago

Hi,

I was wondering if the state could be changed to error when a ClientException is thrown. It is probably only needed for specific cases. Let me explain. Sometimes I get a ClientException with the message Broken pipe or closed connection. or Could not write data to socket.. when using the synchronise Client. I tried different heartbeat settings, but sometimes due to synchronise blocking processing in the application the heartbeat comes to late and the connection is dropped by RabbitMQ. The internal state of the client will remain in a connected state. Calling disconnect or unsetting the Client instance will result in the same Exception. I would be happy to provide a PR, but before I do that I want to make sure the idea is a good one ;) In the synchronise Client in the methods read and write the ClientException is thrown. At that point before the exception is thrown, I'm planning to set the state there to error.

Let me know if this is clear enough.