Monday, October 14, 2013

Making web requests with long timeouts on Windows Phone

It's quite common (I've seen/heard it several times) for people to want to make web requests from their app and have a very long time out. I.E. a timeout longer than 60 seconds.

Despite what you try there's no way to do this though.

That's right. Internally your web request will time out after sixty seconds. This means that while you can create a shorter timeout, you can't create one longer than this.



This shouldn't matter!
60 seconds is a lifetime on a mobile device. As a user, would you want to stare at your device for over a minute while your wait for new data to be loaded? Of course not.

But what if the server takes a long time to generate the data to return?
Then I'd suggest that this should be addressed in different ways:
  • Have the server process faster.
  • Have the server return some of the data initially while it prepares the rest for later.
  • Have the server return some cached data while it gets the latest.
  • Have the server push the data when it is available rather than relying on the app making requests for it.

Ultimately the "best" solution for this scenario will depend on your app, the data and the server. What you shouldn't do though is have the person using your app wait any longer than they absolutely have to.


Update: See a follow up post at Alternatives to long web requests with long timeouts



0 comments:

Post a Comment

I get a lot of comment spam :( - moderation may take a while.