有时我会出错“;连接上意外的流结束”;从android调用web服务时
有时,我在使用go daddy服务器和主机从android调用web服务时遇到错误“连接时流的意外结束” 在关键时刻,我的申请得到了批准 AppController.class有时我会出错“;连接上意外的流结束”;从android调用web服务时,android,mysql,rest,web-services,Android,Mysql,Rest,Web Services,有时,我在使用go daddy服务器和主机从android调用web服务时遇到错误“连接时流的意外结束” 在关键时刻,我的申请得到了批准 AppController.class private void initRetrofitConfig() { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggi
private void initRetrofitConfig() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(interceptor)
.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder().addHeader("Connection", "close").build();
return chain.proceed(request);
}
})
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(1, TimeUnit.MINUTES)
.writeTimeout(5, TimeUnit.MINUTES)
.retryOnConnectionFailure(true)
.build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.baseUrl(SERVICE_URL)
.addConverterFactory(ScalarsConverterFactory.create())
.build();
apiEndpoint = retrofit.create(ApiEndpoint.class);
}
public ApiEndpoint getApiEndpoint() {
if (apiEndpoint == null) {
initRetrofitConfig();
}
return apiEndpoint;
}
检查这个检查这个