Set connection timeout for Parse queries
Asked Answered
C

1

12

I'm testing a query on Parse using the findInBackground() method under different connection types. When connection is not available, there are times in which the done() callback returns, as expected, the following exception after few seconds:

com.parse.ParseException: i/o failure: org.apache.http.conn.HttpHostConnectException: Connection to https://api.parse.com refused

But there are times in which it takes like 30-60 seconds to be thrown, or even is not called at all.

Is there a way to control this behavior? I would like to set a fixed timeout, like 10 seconds.

Combe answered 11/7, 2014 at 7:50 Comment(0)
P
6

You could have your own timer that starts when you run findInBackground. If the timer is exceeded before findInBackground responds, then you could update you app appropriately. When the findInBackground finally does respond back, you can ignore the response.

If you tell me which language you're using, I could probably come up with actual code if you'd like.

Pb answered 9/9, 2014 at 16:39 Comment(1)
Thanks for the tip, I've already implemented this method by myself. I just hoped there was a "native" functionality in the Parse SDK for this purpose, but apparently not.Combe

© 2022 - 2024 — McMap. All rights reserved.