Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 46
Feature/no connection serial recovery key#980
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
Merged
sacOO7
merged 23 commits into
feature/no-connection-serial
from
feature/no-connection-serial-recovery-keyDec 1, 2023
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
fe52c3f
Implemented connectionRecoveryKey
sacOO7 c3e7576
Renamed file to recoverykeycontext
sacOO7 2549547
Added a test to check for encoded recovery key
sacOO7 c767de2
Added test for encoding and decoding recovery key
sacOO7 25b9cdc
Added channel serial to channel properties
sacOO7 a7938e3
Added method to set channelSerials from recover option
sacOO7 2a8bbbd
Added method for getting channel serials to Channels class
sacOO7 6461967
Marked recoveryKey field as deprecated
sacOO7 1897227
Merge branch 'feature/no-connection-serial' into feature/no-connectio…
sacOO7 180d68f
Added explicit method for creating a recovery key
sacOO7 1509938
Simplified recoveryKeyContext class
sacOO7 169392e
Setting recovery key and serials from clientOption
sacOO7 c6af891
Refactored recoverykey to use createRecoveryKey method
sacOO7 e7dc410
Removed all connection serial references from the code
sacOO7 130305b
Added explicit null checks for recoveryKey
sacOO7 3c04523
Implemented channel serial for message reeived
sacOO7 0efffdf
Added missing implementation for channel detach when attached msg rec…
sacOO7 3ebeed7
Updated code to send explicit detach message when attached received in
sacOO7 d465489
Clearing channel serial as per RTP5a1
sacOO7 b42ff87
resetting message serial on failed connection resume or recover
sacOO7 5b8ab5e
Fixed AblyRealtime as class imports
sacOO7 bb42aea
refactored ably protocol and agent headers in accordance with version id
sacOO7 5b8e5b7
Updated test for protocol version
sacOO7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27 lib/src/main/java/io/ably/lib/transport/ConnectionManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -34,6 +34,7 @@ | ||
| import io.ably.lib.util.Log; | ||
| import io.ably.lib.util.PlatformAgentProvider; | ||
| import io.ably.lib.util.ReconnectionStrategy; | ||
| import io.ably.lib.util.StringUtils; | ||
| public class ConnectionManager implements ConnectListener { | ||
| final ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); | ||
| @@ -1193,19 +1194,23 @@ public void onMessage(ITransport transport, ProtocolMessage message) throws Ably | ||
| } | ||
| private void onChannelMessage(ProtocolMessage message) { | ||
| if(message.connectionSerial != null) { | ||
| connection.serial = message.connectionSerial.longValue(); | ||
| if (connection.key != null) | ||
| connection.recoveryKey = connection.key + ":" + message.connectionSerial; | ||
| } | ||
| channels.onMessage(message); | ||
| connection.recoveryKey = connection.createRecoveryKey(); | ||
| } | ||
| private synchronized void onConnected(ProtocolMessage message) { | ||
| final ErrorInfo error = message.error; | ||
| boolean reattachOnResumeFailure = false; // this will indicate that channel must reattach when connected | ||
| // event is received | ||
| boolean isConnectionResumeOrRecoverAttempt = !StringUtils.isNullOrEmpty(connection.key) || | ||
| !StringUtils.isNullOrEmpty(ably.options.recover); | ||
| boolean failedResumeOrRecover = !message.connectionId.equals(connection.id) && message.error != null; // RTN15c7, RTN16d | ||
| if (isConnectionResumeOrRecoverAttempt && failedResumeOrRecover) { // RTN15c7 | ||
| msgSerial = 0; | ||
| } | ||
| ably.options.recover = null; // RTN16k, explicitly setting null, so it won't be used for subsequent connection requests | ||
| connection.reason = error; | ||
| if (connection.id != null) { // there was a previous connection, so this is a resume and RTN15c applies | ||
| Log.d(TAG, "There was a connection resume"); | ||
ttypic marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @@ -1240,12 +1245,6 @@ private synchronized void onConnected(ProtocolMessage message) { | ||
| connection.id = message.connectionId; | ||
| if(message.connectionSerial != null) { | ||
| connection.serial = message.connectionSerial; | ||
| if (connection.key != null) | ||
| connection.recoveryKey = connection.key + ":" + message.connectionSerial; | ||
| } | ||
| ConnectionDetails connectionDetails = message.connectionDetails; | ||
| /* Get any parameters from connectionDetails. */ | ||
| connection.key = connectionDetails.connectionKey; //RTN16d | ||
| @@ -1260,6 +1259,9 @@ private synchronized void onConnected(ProtocolMessage message) { | ||
| requestState(transport, new StateIndication(ConnectionState.failed, e.errorInfo)); | ||
| return; | ||
| } | ||
| connection.recoveryKey = connection.createRecoveryKey(); | ||
| /* indicated connected currentState */ | ||
| final StateIndication stateIndication = new StateIndication(ConnectionState.connected, error, null, null, | ||
| reattachOnResumeFailure); | ||
| @@ -1504,7 +1506,6 @@ private class ConnectParams extends TransportParams { | ||
| ConnectParams(ClientOptions options, PlatformAgentProvider platformAgentProvider) { | ||
| super(options, platformAgentProvider); | ||
| this.connectionKey = connection.key; | ||
| this.connectionSerial = String.valueOf(connection.serial); | ||
| this.port = Defaults.getPort(options); | ||
| } | ||
| } | ||
| @@ -1905,7 +1906,7 @@ private boolean isFatalError(ErrorInfo err) { | ||
| private boolean suppressRetry; /* for tests only; modified via reflection */ | ||
| private ITransport transport; | ||
| private long suspendTime; | ||
| private long msgSerial; | ||
| public long msgSerial; | ||
| private long lastActivity; | ||
| private CMConnectivityListener connectivityListener; | ||
| private long connectionStateTtl = Defaults.connectionStateTtl; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.