0

My Android application has started failing as follows when POSTing large (17048 Bytes) API requests

2019-09-20 08:20:01.198 15645-15862/org.aaa.bbb.ccc.mycompany D/GraphqlNetworkControlle: mutation {"operationName":"myOperation","variables":{"uuids":["
2019-09-20 08:20:01.207 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: --> POST https://mycompany.com/graphql
2019-09-20 08:20:01.208 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: Content-Type: application/json
2019-09-20 08:20:01.208 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: Content-Length: 17048
2019-09-20 08:20:01.208 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: authorization: Bearer eyJrauYhjiknbgsdsRPS0VOIiwiYWxnIjoiRVMyNTYifQ.eyJzdWIiOiJk
2019-09-20 08:20:01.208 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: --> END POST
2019-09-20 08:20:01.213 15645-15862/org.aaa.bbb.ccc.mycompany D/OkHttp: <-- HTTP FAILED: java.io.InterruptedIOException: interrupted
2019-09-20 08:20:01.215 15645-15862/org.aaa.bbb.ccc.mycompany E/PendingMutationSO: processError()
    java.io.InterruptedIOException: interrupted
        at okio.Timeout.throwIfReached(Timeout.kt:98)
        at okio.OutputStreamSink.write(Okio.kt:53)
        at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:106)
        at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:181)
        at okio.RealBufferedSink.write(RealBufferedSink.kt:39)
        at okhttp3.internal.http2.Http2Writer.dataFrame(Http2Writer.kt:165)
        at okhttp3.internal.http2.Http2Writer.data(Http2Writer.kt:153)
        at okhttp3.internal.http2.Http2Connection.writeData(Http2Connection.kt:320)
        at okhttp3.internal.http2.Http2Stream$FramingSink.emitFrame(Http2Stream.kt:539)
        at okhttp3.internal.http2.Http2Stream$FramingSink.write(Http2Stream.kt:510)
        at okio.ForwardingSink.write(ForwardingSink.kt:29)
        at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:222)
        at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:181)
        at okio.RealBufferedSink.write(RealBufferedSink.kt:92)
        at okhttp3.RequestBody$Companion$toRequestBody$2.writeTo(RequestBody.kt:147)
        at retrofit2.RequestBuilder$ContentTypeOverridingRequestBody.writeTo(RequestBuilder.java:283)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:59)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:215)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)

Is a request of 17048 bytes "Too Big" or should Retrofit be able to handle this?

Is this a "Back end" issue?

Is there anyway I can resolve this issue on the client side?

I configure retrofit as follows:-

internal val okHttpClient:OkHttpClient = configure()

    private fun configure(): OkHttpClient {

        val okHttpClientBuilder: OkHttpClient.Builder = OkHttpClient.Builder()
                .connectTimeout(OK_HTTP_CLIENT_TIMEOUT, TimeUnit.MILLISECONDS)
                .readTimeout(OK_HTTP_CLIENT_TIMEOUT, TimeUnit.MILLISECONDS)
                .writeTimeout(OK_HTTP_CLIENT_TIMEOUT, TimeUnit.SECONDS)
                .callTimeout(OK_HTTP_CLIENT_TIMEOUT, TimeUnit.MILLISECONDS)
                .followSslRedirects(true)
                .retryOnConnectionFailure(true)
                .followRedirects(true)

        return okHttpClientBuilder.build()
    }

    companion object {

        private const val OK_HTTP_CLIENT_TIMEOUT: Long = 60000

    }
Hector
  • 4,016
  • 21
  • 112
  • 211
  • 1
    Your request might failed due to reason that it took longer than your `writeTimeout` to execute for your particular API. – Jeel Vankhede Sep 20 '19 at 07:43
  • @JeelVankhede my writetimeout is 60000 SECONDS, thats 16.66667 HOURS – Hector Sep 20 '19 at 07:47
  • Check out this issue, it's similar to yours.. https://github.com/square/retrofit/issues/931 – Jeel Vankhede Sep 20 '19 at 07:52
  • 1
    The timeout you set on retrofit is not the only timeout. Backend also has a timeout on how long to keep the connection open and if you use something like nginx it might also have timeout. If your application will have multiple users then this solution is a no go, since number of connections at the same time are limited. – Daniel Sep 20 '19 at 09:38

0 Answers0