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

[INV-3715] Use Network to determine online status v1 #3722

Closed
wants to merge 8 commits into from

Conversation

LocalNewsTV
Copy link
Collaborator

@LocalNewsTV LocalNewsTV commented Nov 27, 2024

Overview

This PR includes the following proposed change(s):

Handling These Network Scenarios

  • Initial Network State
  • Manual User Disconnect/Reconnect
  • Rolling API checks to maintain current network status
  • Automatic re-attempts to connect if disconnected

V2 Iteration can use Websockets to abstract all this work.

Changes:

All changes affect Mobile Only

  • Closes Utilize Health Check to determine if Online/Offline #3715
  • Do one test connection against API to determine initial Network state for Online/Offline
    • The multi-checks before fail for the normal loop resolves too slow to be effective at start
  • Begin Network loop when User attempts to come online
  • Cancel Network loop when user goes offline
  • Monitor Network connection through API calls, similarly to how auth tokens are updated.
  • If User determined offline, communicate to user, then attempt to reconnect in background. Alert user if these reconnect attempts fail

meghna0593
meghna0593 previously approved these changes Nov 28, 2024
@LocalNewsTV LocalNewsTV changed the title [INV-3715] Use Network to determine online status [INV-3715] Use Network to determine online status v1 Nov 28, 2024
}
yield delay(SECONDS_BETWEEN_CHECKS * 1000);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

a single do-while loop should suffice? You have about 5 attempts going on here with a delay of 5 seconds. You can increase the MAX_ATTEMPTS and remove the outer while loop or increase SECONDS_BETWEEN_ATTEMPTS.

Copy link
Collaborator Author

@LocalNewsTV LocalNewsTV Nov 29, 2024

Choose a reason for hiding this comment

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

@meghna0593
the while(true) loop is always pinging the API to ensure continued connection unless otherwise cancelled (by a user choosing to go offline, or being disconnected and unable to reconnect)

If that do-while fetch request fails and we are UNABLE to reach our API, we don't want to immediately panic, so we send a few more requests at a faster interval to see if anything will come back. If we still can't reach the API we will trigger Offline mode.

While in offline mode, we will sporadically try a few more attempts to come back online.

In the end this is just v1 functionality, it will be succeeded by WebSockets or some similar network equivalent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Originally this PR was VERY different than it is now.
The previous code you reviewed still had a handle_CHECK_MOBILE_NETWORK_STATUS function, but the logic for it is black and white compared to the logic I explained it in call :)
Sorry for any confusion !

Copy link
Collaborator

Choose a reason for hiding this comment

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

if this was intended to be on an infinite loop when canConnect is true, then do you think this could be blocking in nature? Maybe making this a background task is worth looking at? @plasticviking thoughts?

app/src/state/sagas/network.ts Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@LocalNewsTV LocalNewsTV closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Utilize Health Check to determine if Online/Offline
3 participants