Skip to content

Suspend timer is set when transport is unavailable and last state was connected#928

Merged
AndyTWF merged 8 commits intomainfrom
925-connection-suspension-after-long-connection
Mar 21, 2023
Merged

Suspend timer is set when transport is unavailable and last state was connected#928
AndyTWF merged 8 commits intomainfrom
925-connection-suspension-after-long-connection

Conversation

@AndyTWF
Copy link
Contributor

@AndyTWF AndyTWF commented Mar 17, 2023

Previously, a connection that had been connected for longer than the suspend timer period (set in onConnected) would have immediately transitioned to suspended when the transport became unavailable. This is because the timer is not reset the first time the transport fails.

This change fixes this by resetting the suspend timer when the transport becomes unavailable, if the current connection state is connected.

Also included are some unit tests on the connection manager which force the connection into a desired state, and then test the behaviour.

Fixes #925

… connected

Previously, a connection that had been connected for longer than the suspend timer period (set in onConnected)
would have immediately transitioned to suspended when the transport became unavailable. This is
because the timer is not reset the first time the transport fails.

This change fixes this by resetting the suspend timer when the transport becomes unavailable, if
the current connection state is connected.

Fixes #925
@github-actions github-actions bot temporarily deployed to staging/pull/928/features March 17, 2023 12:53 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/928/javadoc March 17, 2023 12:54 Inactive
@AndyTWF AndyTWF requested review from ikbalkaya and paddybyers March 17, 2023 13:55
Copy link
Contributor

@ikbalkaya ikbalkaya left a comment

Choose a reason for hiding this comment

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

Two questions, but looks good to me

Copy link
Member

@paddybyers paddybyers left a comment

Choose a reason for hiding this comment

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

Don't we also need to remove

?

@AndyTWF
Copy link
Contributor Author

AndyTWF commented Mar 20, 2023

Don't we also need to remove

?

There are places elsewhere (such as auth errors) that explicitly request the state Disconnected and rely on this line to reset the timer, so we'd want to make sure the timer is properly set in these instances.

Admittedly, this would mean the timer gets set twice when we have onTransportUnavailable being called. That is, unless we change that method to not set the timer, but just always set disconnected if the last state was connected.

Will have a look to see if this can be tided up a bit!

AndyTWF added 5 commits March 20, 2023 10:12
Can lead to race conditions, plus `onTransportUnavailable` is inherently called by clearing
Much easier to see what's going on when debugging.
@AndyTWF AndyTWF requested review from ikbalkaya and paddybyers March 20, 2023 11:32
@github-actions github-actions bot temporarily deployed to staging/pull/928/features March 20, 2023 11:32 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/928/javadoc March 20, 2023 11:33 Inactive
The connection re-attempt supersedes the transport, which prevents the onTransportUnavailable
call from setting the suspension timer.
@github-actions github-actions bot temporarily deployed to staging/pull/928/features March 21, 2023 12:21 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/928/javadoc March 21, 2023 12:22 Inactive
Copy link
Member

@paddybyers paddybyers left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@AndyTWF AndyTWF merged commit 4752411 into main Mar 21, 2023
@AndyTWF AndyTWF deleted the 925-connection-suspension-after-long-connection branch March 21, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Long-lived connections are immediately transitioned to SUSPENDED after disconnection

3 participants