-
Notifications
You must be signed in to change notification settings - Fork 101
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 an activity timeout configuration option #241
Conversation
The current `activity_timeout` option when establishing a connection was hardcoded to 30 seconds, but sometimes we need our application to ping at a different rate. This value should be configured through the proper config file using the `ping_interval` option which takes `REVERB_APP_PING_INTERVAL` environment variable or 60 by default. This update takes the value which is loaded onto the `Application` class and is available through the `Connection` class, making this an easy fix.
This change makes sure that all future applications that re-publish the configuration keep the original 30 second value instead of the 60 second default configuration. All applications that modified this value in their environment file should not be affected.
I think that's a good idea finding common ground, I was not sure about the usage of |
…stead of `ping_interval` to separate the concerns and accomplish the same result.
Oops, need to pass some tests, I'll fix this now! |
…finition. Using `30` as the default value as this was the original value in the package.
Drafting this pending review from @joedixon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a minor tweak to set the default value to prevent a breaking change, but otherwise this looks good, thanks!
The reason why I am proposing this change is because I actually need this in my own application, where there is one reverb app that I need to ping constantly (every 5 seconds). Plus, I frankly do not understand why there is a
ping_interval
configuration if it is not used at all except for checking whether you are active or not. In fact, what defines being active is something we should all set for ourselves based on our business rules when developing apps and this rule may vary from application to application, like in my case.As for breaking existing features, the one thing I would point out is that the default setting in the configurations is
60
seconds, whilst in this branch it was hardcoded to30
seconds. So, if people were expecting the app to ping every30
seconds, this should remain unchanged. Therefore, I also changed the configuration file to default to30
such that the behavior does not change for those who did not set the environment value.I believe this makes building web applications better because it makes sense out of the configuration and it is an important feature of real-time applications. Being able to change this on an application-basis and quickly via a configuration file and environment variables is a huge advantage for developers, in my honest opinion.
As per tests, I obviously tested this locally and my application indeed started pinging every 5 seconds rather than 30, but I do not really see how to provide a test for this here. This is, after all, my first contribution to any open source repository, and I am not used to it. In any case, I could provide a screenshot showing the results later in comments.
I deeply apologize to everyone if this change is not the intended behavior and I am just talking nonsense, but it really fixes my personal problem and is what I needed. I will understand if this PR is not approved. And, by the way, I would even suggest changing the variable name from
$pingInterval
to$activityTimeout
, since it makes more sense for the app. Even for theLaravel\Reverb\Contracts\Connection::isActive()
function.Thank you for an amazing solution to WebSockets!