question

DavidMecteaux-3493 avatar image
0 Votes"
DavidMecteaux-3493 asked DavidMecteaux-5019 commented

Working with very bad internet connectsion

Hello,

I have been developing a app that has a online mode and a offline mode. Both modes are working as expected. But the issue that some of our users are having is that their internet connection in some areas is so bad that they drop and connect quite often. Or if they stay connected their internet connections are so slow it causes our Web API's to time out.

My question is there a way to detect if the user has a lousy connection? If I can detect this then I can treat the app as if it is in the offline mode.

Thanks.

---Dave

dotnet-csharpdotnet-xamarin
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

No and it would be no better than if you could detect if they were driving lousy cars or trucks. :) The best you can do is have them get a better ISP (Internet Service Provider).

0 Votes 0 ·

Our customers are farmers. Some of these farms are in fairly remote locations in the U.S and they actually do not have cellular signals (or the cellular signals are really lousy) when they are in their fields.

0 Votes 0 ·

Hello,

Starlink may start to roll out and be available in rural farm areas already. Have your app users check availability. They are promising high bandwidth, low latency and affordability.

-Miguel Fra
Falcon IT Services
https://cloud.falconitservices.com
'

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered DavidMecteaux-5019 commented

You can add a health ping. A small request the client times. You can decide on thresholds. You should check the runtime of all network call, you can treat too long like a failure, and move to offline mode. When in offline mode, use the health check to back online.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Your pinging idea is very interesting. I think I will test this out. I have a method called SyncData and I could ping right before that method to figure out how the connection is. My concern is that if I have a few hundred users pinging all the time....that wouldn't exactly be ideal. Especially if most of the user's connection are just fine.

0 Votes 0 ·

Hello,

You may want to consider working in off-line mode then, at a specified time interval, check connection reliability with a series of pings, synch the data and then go back to off-line mode. This will decrease your bandwidth requirement at the server or hub site. We use several security apps that do it this way and they work very well.

.

0 Votes 0 ·

I am doing something very similar to that. All new data / pics the farmer enters in goes through that SyncData method to update the data on the server. If also has this code:
if (Connectivity.NetworkAccess == NetworkAccess.Internet)
when it tries to update any new data on the server. That if statement could be called multiple times every time it tries to update and create data.

0 Votes 0 ·
falconitservices avatar image
0 Votes"
falconitservices answered DavidMecteaux-5019 commented

Hello,

You can detect bad connections by the latency returned from a Ping. Also, packet loss would be a good indicator of connection problems.

If you can have your app ping your server (phone home) and capture and measure packet loss and latency, you can create an algorithm and tweak it to detect thresholds that are within tolerable range of your apps on-line/off-line mode.

Miguel Fra
Falcon IT Services
https://www.falconitservices.com

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is there a good library that I could use to ping that will work on iOS and Android devices? I see there is a nuget package called Xamarin.SinplePing but that seems like it is only for iOS.

0 Votes 0 ·
GaryNebbett avatar image
0 Votes"
GaryNebbett answered GaryNebbett commented

Hello @DavidMecteaux-5019,

It might be worth looking at the GetPerTcpConnectionEStats API. One of the items that this API can provide is:

 typedef struct _TCP_ESTATS_BANDWIDTH_ROD_v0 {
   ULONG64 OutboundBandwidth;
   ULONG64 InboundBandwidth;
   ULONG64 OutboundInstability;
   ULONG64 InboundInstability;
   BOOLEAN OutboundBandwidthPeaked;
   BOOLEAN InboundBandwidthPeaked;
 } TCP_ESTATS_BANDWIDTH_ROD_v0, *PTCP_ESTATS_BANDWIDTH_ROD_v0;

Gary


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is there a C# version of this that can be used by Android / iOS?

0 Votes 0 ·

Hello David,

As far as I know, that API can only be used from C# via interop - I don't think that there are any framework classes that expose it. Some aspects of TCP Extended Statistics are standardized (e.g. RFC 4898) but I don't know if the data is exposed by Android or iOS.

Gary

0 Votes 0 ·