D/OkHttp: --> GET https://example.com:PORT/... http/1.1
Authorization: Bearer example token
Device-Type: Android
--> END GET
我只看到请求信息,不会得到任何错误/响应。
我使用Retrofit和Okhttp。
配置如下:
private val timeOut: Long = 30 * 1000
private val cacheSize: Long = 10 * 1024 * 1024 // 10 MB
private var cache = Cache(presenterLayer.getCacheDir(), cacheSize)
private val client: OkHttpClient = OkHttpClient.Builder()
.addInterceptor(RedirectInterceptor())
.addInterceptor(TokenInterceptor(presenterLayer))
.addInterceptor(Logger(presenterLayer))
.cache(cache)
.sslSocketFactory(CustomTrust.getSSLConfig().socketFactory)
.followRedirects(false)
.followSslRedirects(false)
.connectTimeout(timeOut, TimeUnit.SECONDS)
.readTimeout(timeOut, TimeUnit.SECONDS)
.writeTimeout(timeOut, TimeUnit.SECONDS)
.build()
private val retrofit = Retrofit
.Builder()
.baseUrl(presenterLayer.getBaseUrl())
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
我的问题是:除了网络之外,这种情况发生在什么时候,具体发生了什么?
发布于 2018-06-17 19:15:45
试用timeOut的TimeUnit.MILLISECONDS
并检查错误请求
private val timeOut: Long = 30 * 1000
.connectTimeout(timeOut, TimeUnit.MILLISECONDS)
.readTimeout(timeOut, TimeUnit.MILLISECONDS)
.writeTimeout(timeOut, TimeUnit.MILLISECONDS)
https://stackoverflow.com/questions/50889898
复制相似问题