Как разрешить Retrofit запись из Timimg Out при размещении больших запросов - PullRequest
0 голосов
/ 20 сентября 2019

Мое приложение Android перестало работать, как показано ниже, при отправке больших (17048 байт) API-запросов

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)

Является ли запрос 17048 байт "слишком большим", или Retrofit сможет обработать это?

Это проблема «Back-end»?

Есть ли возможность решить эту проблему на стороне клиента?

Я настраиваю модификацию следующим образом: -

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

    }
...