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

Fix freeze on reconnection attempts #54

Merged
merged 11 commits into from
Apr 23, 2021
Merged

Conversation

Shiranuit
Copy link
Contributor

@Shiranuit Shiranuit commented Apr 20, 2021

What does this PR do ?

This PR aims to fix a bug that occurs when trying to reconnect and that freezes the SDK during the reconnection

  • tryToReconnect now returns a CompletableFuture<Boolean> instead of a Boolean
  • The connect method now chains CompletableFutures to resolve the connection / reconnection

Other

  • Add infinite reconnection attempts by setting it to -1
  • Disconnect now cancel the reconnection attempts

@Shiranuit Shiranuit self-assigned this Apr 20, 2021
@Shiranuit Shiranuit changed the base branch from master to 1-dev April 20, 2021 11:42
@Shiranuit Shiranuit linked an issue Apr 20, 2021 that may be closed by this pull request
@@ -21,6 +21,7 @@ import java.net.ConnectException
import java.net.SocketException
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.atomic.AtomicBoolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a simple boolean not sufficient?

Copy link
Contributor Author

@Shiranuit Shiranuit Apr 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are doing the check in an other thread (CompletableFuture) which means we need an AtomicBoolean to avoid race conditions with the disconnect method that might be call from a different thread

@Yoann-Abbes Yoann-Abbes merged commit 6698879 into 1-dev Apr 23, 2021
@Yoann-Abbes Yoann-Abbes deleted the 53-fix-freeze-on-reconnection branch April 23, 2021 07:12
@Shiranuit Shiranuit mentioned this pull request May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug/Regression] SDK Freezes when autoReconnecting
3 participants