Skip to content
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

Add the sendHeartbeat method to the AbstractClient class #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petaak
Copy link

@petaak petaak commented Mar 7, 2019

In a long running consumer I need to send the heartbeat frames periodically to prevent the client disconnection.

@jakubkulhan
Copy link
Owner

Hello Petr! There has already been similar PR - see #7. I don't think this is a good idea to expose such low-level protocol method in public API. Please set heartbeat option in constructor appropriately that you always finish blocking work within the specified interval. Heartbeat is mostly useful for keeping open connection that crosses loadbalancers or WAN. If you connect to RabbitMQ directly on LAN, you can set heartbeat in order of tens of minutes and everything should be fine.

@sztanpet
Copy link

I don't think you can get away from exposing this functionality, otherwise how would you solve the problem of a long-running task that takes an unknown amount of time?
For example a video conversion where the conversion can take a different amount of time depending on the length of a video?

@bckp
Copy link

bckp commented May 11, 2021

Well, if you only produces messages, like we do, heartbeat need to be exposed, becouse simply in publish only mode, you must keep sending it by yourself... We publish message some times only once per 30 minutes, that couse of exception becouse socket is closed already... So our app should keep sending heartbeat once per 30 seconds, so we do not exceed socket timeout and keep connection alive.

So far we just extends Client and add public method Heartbeat :)

Btw: setting this heartbeat option in config will not help you, in case you onlu producting messages. Bunny will not be called unless there is message to deliver, but since some time can pass, connectino is already closed... This is why we need sendHeartbeat or somethink similar, can be somethink like imAlive(), and internally you can send heartbeat if time is passed and is required to.

@bckp
Copy link

bckp commented May 11, 2021

ping @jakubkulhan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants