Error handler invoked when no connectivity even if cache hit

996 views
Skip to first unread message

Nick Moukhine

unread,
Sep 2, 2014, 2:11:25 PM9/2/14
to volley...@googlegroups.com
Hi,

Just wondering if this is expected behavior:

I make an rpc onResume, the header specifies the request can be cached
I put the phone into airplane mode
I return to the app and the same url is requested again
Volley invokes error handler:
java.net.UnknownHostException: Unable to resolve host "<my server>": No address associated with hostname


I would expect a cache hit and no error.  I always assumed that the offline cache use case would just come for free with volley.  Am I wrong?

Thanks,
-Nick

Ficus Kirkpatrick

unread,
Sep 2, 2014, 2:48:33 PM9/2/14
to Nick Moukhine, volley...@googlegroups.com
This is not expected. I suspect you are not seeing a cache hit. Can you paste a logcat dump with verbose logging enabled?

Run adb shell setprop log.tag.Volley VERBOSE

then restart your app and reproduce.

Ficus




--
You received this message because you are subscribed to the Google Groups "Volley Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to volley-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Moukhine

unread,
Sep 2, 2014, 4:49:10 PM9/2/14
to volley...@googlegroups.com, o...@google.com
Here's a logcat.  Don't mind the double-load at the beginning, looks like Volley handles it just fine.  24 secs later I resume the app without wifi and see a cache expire.  I've hit the same url in my browser and verified the response has max-age=900

09-02 13:30:15.152  18953-18974/com.example.app D/Volley﹕ [2219] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] https://myserver.com/api/v1.4/article/687269 0x30387d8e NORMAL 11> [lifetime=1656], [size=10170], [rc=200], [retryCount=0]
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (1732 ms) [ ] https://myserver.com/api/v1.4/article/687269 0x30387d8e NORMAL 11
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2218] cache-queue-take
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2218] cache-miss
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2219] network-queue-take
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+1657) [2219] network-http-complete
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+64  ) [2219] network-parse-complete
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+10  ) [2219] network-cache-written
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2219] post-response
09-02 13:30:15.232  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+1   ) [ 1] done
09-02 13:30:15.863  18953-18976/com.example.app D/Volley﹕ [2221] BasicNetwork.logSlowRequests: HTTP response for request=<[ ] https://myserver.com/api/v1.4/article/687269 0x30387d8e NORMAL 12> [lifetime=600], [size=42], [rc=200], [retryCount=0]
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (610  ms) [ ] https://myserver.com/api/v1.4/article/687269 0x30387d8e NORMAL 12
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2218] cache-queue-take
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2218] cache-miss
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2221] network-queue-take
09-02 13:30:15.873  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+600 ) [2221] network-http-complete
09-02 13:30:15.883  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+1   ) [2221] network-parse-complete
09-02 13:30:15.883  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+9   ) [2221] network-cache-written
09-02 13:30:15.883  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2221] post-response
09-02 13:30:15.883  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [ 1] done
09-02 13:30:39.856  18953-18953/com.example.app D/com.example.app.base.request.GlobalRpcErrorHandler﹕ com.android.volley.NoConnectionError: java.net.UnknownHostException: Unable to resolve host "myserver.com": No address associated with hostname
09-02 13:30:39.856  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (142  ms) [ ] https://myserver.com/api/v1.4/article/687269 0x30387d8e NORMAL 13
09-02 13:30:39.856  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [ 1] add-to-queue
09-02 13:30:39.856  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+2   ) [2218] cache-queue-take
09-02 13:30:39.856  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+23  ) [2218] cache-hit-expired
09-02 13:30:39.856  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+0   ) [2222] network-queue-take
09-02 13:30:39.866  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+6   ) [2222] post-error
09-02 13:30:39.866  18953-18953/com.example.app D/Volley﹕ [1] MarkerLog.finish: (+111 ) [ 1] done
 

Thanks,
-Nick

ps happy to provide unobfuscated info if that helps eliminate other possibilities.

Ficus Kirkpatrick

unread,
Sep 2, 2014, 6:48:06 PM9/2/14
to Nick Moukhine, volley...@googlegroups.com
Well, as you can see, it thinks the entry is expired. I'd take a look at all the headers that are returned. Date, Cache-Control, and Expires can all have effect. Here's the parsing code:



--

Nick Moukhine

unread,
Oct 7, 2014, 6:58:41 PM10/7/14
to volley...@googlegroups.com, o...@google.com
Hey Ficus, I stepped through the code and the issue seems to be case sensitivity.  I have "cache-control" in my response but Volley expects "Cache-Control".   Seems like the header keys should be case insensitive:  http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive

-Nick

Ralph Bergmann | the4thFloor.eu

unread,
Oct 8, 2014, 3:01:11 AM10/8/14
to volley...@googlegroups.com
Hello,


looks that we have to discuss about
https://android-review.googlesource.com/#/c/62252/


Ralph


Am 08.10.14 00:58, schrieb Nick Moukhine:
signature.asc

Ralph Bergmann | the4thFloor.eu

unread,
Oct 8, 2014, 11:16:56 AM10/8/14
to volley...@googlegroups.com
Hello,


I uploaded a new patch to solve this problem:
https://android-review.googlesource.com/#/c/110241

This solution doesn't change the keys.


Ralph


Am 08.10.14 00:58, schrieb Nick Moukhine:
signature.asc

Ficus Kirkpatrick

unread,
Oct 8, 2014, 11:42:59 AM10/8/14
to Ralph Bergmann | the4thFloor.eu, volley...@googlegroups.com
Clever! Will go through reviews this afternoon
Reply all
Reply to author
Forward
0 new messages