Best Way to Handle Connection Timeout?

Best Way to Handle Connection Timeout?


Hi All

We have a mobile application that has offline capabilities. We have the data sync in process (in compliance to the OS guides), and a couple of server actions that handle other synchronization. When a user performs a save or delete action (for example), we always check if there is network connectivity, and if there is, we call the server actions (if there is not then we only save it locally). When the user has either good connection, or no connection at all, this logic works well. However, when the user has 'iffy' connection at best, the GetNetworkStatus() action returns true, but the server action is timing out, since it looks like the connection cuts midway or is too slow to retrieve all necessary data. We have thought of some solutions

  • Use the get network type and only allow 3G or WiFi. This would disable slower networks, however this does not completely solve the problem, since WiFi and/or 3G can have the same issues depending on the network
  • Place an exception handler where if it is a Connection Timeout exception, we call the execution of the server action again. A sort of re-try.
  • Place an exception handler where if it is a Connection Timeout exception, we call for a complete offline data sync.

Using a complete offline sync every single time is not feasible, since it would be a massive data usage.

Note: This does not happen when doing the offline sync, since that does have exception handlers, just when we call our own server logic.

Does anyone have any experience handling this type of problem? If so, could you share your solutions? Thanks in advance!

TD;LR What is the best way to handle mobile connection timeouts?



My favorite approach for the last 15 years is to save locally and synchronization is by time in both ways (Last sync datetime is also saved in local tables).

For your scenario a lastsync by table makes sense. You keep trying to sync in the background, without affecting the user experience. Maybe a warning before he leaves that not everything is yet synced.