app
app copied to clipboard
feat: status check for internet connection
Currently the code is ready for merge, we need to decide what and how should we handle tracking internet connection updates.
The approach I have implemented below is,
- Every 60 seconds make a network request to verify if we still have a live internet connection.
- Send event about the status after the request verifies the status to JS.
- Hold a receiver on Rust end that can also handle certain actions if internet status changes (reconnecting to prem network, etc).
Open Questions that need discussion:
- Whom and how should we make net requests. Eg,
- Make ICMP request to say 8.8.8.8 to verify internet is available.
- Make TCP/HTTP request to some always available website like google or etc to verify network connectivity.
- Make HTTP request to registry to verify internet connectivity.
The advantages of the first is that it's cheap and we can ping dozens of servers as once, to ensure we have little to no false positive. But ICMP doesn't represent that webservers are also working, and in certain cases it may not reflect the applications ability to connect to internet.
The advantages of the second is even though it's heavier but we can in general verify that internet over TCP/HTTP is definitely available but will have the risk of not representing availability of registries.
The advantages third is it's very accurate, but it's also comes with the risk of causing rate limiting over registries or over burdening the registries(imagine if someone adds their own registries without realizing they might be bombarded by requests just for connectivity check).