Я использую следующие зависимости (Retrofit и OkHttp).
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
Ниже мой код:
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(cache_interceptor)
.cache(cache)
.connectTimeout(AppConstants.TIME_OUT, TimeUnit.SECONDS)
.readTimeout(AppConstants.TIME_OUT, TimeUnit.SECONDS)
.writeTimeout(AppConstants.TIME_OUT, TimeUnit.SECONDS)
.connectionSpecs(Collections.singletonList(ConnectionSpec.CLEARTEXT))
.retryOnConnectionFailure(false)
.build();
return new Retrofit.Builder()
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(okHttpClient)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BuildConfig.BASE_URL).build();
private final Interceptor cache_interceptor = new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder().addHeader("Connection", "close").build();
return chain.proceed(request);
}
};
URL-адрес https один, указывающий на AWS S3 экземпляр.
Но я получаю следующую ошибку для https
конечной точки URL.
java.io.IOException: непредвиденное завершение потока в соединении1020 *
Прошел через похожие темы, такие как Обсуждение Github 1 и Обсуждение Github 2 , но не смог найти разрешение.
Если я заменил https с http , также нет проблем или ошибок !!
Есть идеи, что может быть причиной проблемы?