android 7.1.1 (Nougat) app standby and network
H

0

11

I need to issue network calls when the app is in background. The sequence is as following. The app receives GCM call, issues API call to BE in order to get some more data, and then show notification. The GCM call is received perfectly, but the API network call is failed by timeout with the following stack-trace:

java.net.SocketTimeoutException: timeout
    at okio.Okio$3.newTimeoutException(Okio.java:207)
    at okio.AsyncTimeout.exit(AsyncTimeout.java:250)
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:217)
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
    at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
    at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
    at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
    at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:87)
    at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:722)
    at com.nuro.newcoms.NuroCommunicationService$21.intercept(NuroCommunicationService.java:1986)
    at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:695)
    at com.nuro.encryption.NuroSSLContext$1.intercept(NuroSSLContext.java:94)
    at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:695)
    at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
    at com.squareup.okhttp.Call.getResponse(Call.java:287)
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
    at com.squareup.okhttp.Call.execute(Call.java:80)
    at retrofit.client.OkClient.execute(OkClient.java:53)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
    at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
    at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
    at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:761)

I'm using okhttp ver 2.7.5, retrofit 1.9.0

The app is in background but the device is NOT in doze, the screen is on, and even charging. SO it's can't be DOZE issues.

Happens both on WiFi and 3/4G.

pre-nougat devices don't have this issue.

UPD When the app is selected as "not optimized" in battery setting, everything works like a charm.

Husha answered 3/1, 2017 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.