我正在使用改造,它工作正常,但有时它没有得到连接并抛出SocketException类型的异常,这里是我使用的配置:
版本:
` 'com.squareup.okhttp3: okhttp: 3.5.0'
'com.squareup.retrofit2: retrofit: 2.1.0'`
带有readtimeout,connecttimeout和writetimeout以及Retrofit实例的OkHttpClient:
`...OkHttpClient okHttpClient = new OkHttpClient.Builder ()
.readTimeout (50, TimeUnit.SECONDS)
.connectTimeout (50, TimeUnit.SECONDS)
.writeTimeout (50, TimeUnit.SECONDS)
Retrofit retrofit = new Retrofit.Builder ()
.baseUrl ("endpoint")
.addConverterFactory (GsonConverterFactory.create ())
.client (okHttpClient) .build ();...`
这个配置我用作单例模式。