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 new connection setting for delay between reconnect attempts #130

Merged
merged 1 commit into from
Nov 1, 2022

Conversation

Namoshek
Copy link
Collaborator

@Namoshek Namoshek commented Nov 1, 2022

As discussed in #129, the auto-reconnect feature only offers basic functionality as of right now. This PR therefore adds an additional connection setting for the delay between reconnect attempts setDelayBetweenReconnectAttempts($delay) which can be used in combination with setReconnectAutomatically(true) and setMaxReconnectAttempts($attempts):

$connectionSettings = (new \PhpMqtt\Client\ConnectionSettings)
    ->setReconnectAutomatically(true)
    ->setMaxReconnectAttempts(3)
    ->setDelayBetweenReconnectAttempts(0);

✔️ For backwards compatibility, the default delay between reconnect attempts is zero.
✔️ Integration tests for the auto-reconnect feature do not exist and are almost impossible to write, therefore this PR does not contain any tests. Manual tests have been performed.

⚠️ The setDelayBetweenReconnectAttempts($delay) accepts a $delay in milliseconds, which is different to other (timeout) settings.
⚠️ Whether setting a delay between reconnect attempts makes sense, is up to the user of this library. In some scenarios, there is already some kind of delay given in the form of the connect timeout.

@Namoshek Namoshek added the enhancement New feature or request label Nov 1, 2022
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 1, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

27.3% 27.3% Coverage
0.0% 0.0% Duplication

@Namoshek Namoshek merged commit 22a207e into master Nov 1, 2022
@Namoshek Namoshek deleted the feature/auto-reconnect-delay-between-attempts branch November 1, 2022 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant