Clament John

11/29/2021, 5:37 AM
How do I check for network connectivity status on the Desktop?


11/29/2021, 6:20 AM
Unfortunately, simply asking the network layer below the Application whether it's connected is notoriously unreliable on any platform. There can be many reasons for this; including infrastructure, like proxies, that will happy generate a page explaining why they can't connect... making it look like 'the network' is connected.
General advice seems to be pick a sensible destination (a 'ping' endpoint on your own server, if that makes sense), and actually try to connect to it.

Clament John

11/29/2021, 6:22 AM
Oh. Good to know. So in this case I will need to start a flow/channel that keeps updating the ping status periodically. Got it. Thanks


11/29/2021, 7:09 AM
I think it depends on your case. 95% cases where I see code which tries to use connectivity status on Android is just cause bad UX and will never be reliable enough and covers such pretty simple use cases as no network connection at all, as result it just hides an actual problem of handling of network errors Agree with Chris, your service ping is the only reliable way to do this, but does it needed for your use case or not is another questions, in most cases it’s just unnecessary and proper error handling will work better