「Fix」
1、由于目前http的并发量太大了,临时用增加okhttp队列的方式来解决超时问题。 2、TODO:长期需要对现有Http请求进行梳理管控,对高频次的http请求转到socket中做。 @梁利晖、@钟超
This commit is contained in:
@@ -9,6 +9,7 @@ import com.mogo.cloud.network.cronet.CronetInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpHeaderInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpLoggingInterceptor
|
||||
import com.mogo.cloud.network.interceptor.HttpPassportInterceptor
|
||||
import okhttp3.Dispatcher
|
||||
import okhttp3.OkHttpClient
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -21,20 +22,27 @@ import java.util.concurrent.TimeUnit
|
||||
*/
|
||||
class OkHttpFactory private constructor() {
|
||||
companion object {
|
||||
var dispatcher: Dispatcher = Dispatcher()
|
||||
|
||||
val okHttpClient: OkHttpClient by lazy {
|
||||
//自定义上限,所有总数的最大上限
|
||||
dispatcher.setMaxRequests(3000000);
|
||||
//自定义上限,单个IP+端口的限制
|
||||
dispatcher.setMaxRequestsPerHost(1000000);
|
||||
|
||||
OkHttpClient.Builder()
|
||||
.addInterceptor(HttpHeaderInterceptor())
|
||||
.addInterceptor(HttpPassportInterceptor())
|
||||
.addInterceptor(CronetInterceptor())
|
||||
.addInterceptor(HttpLoggingInterceptor())
|
||||
.sslSocketFactory(createSSLSocketFactory(), createTrustAllManager())
|
||||
.hostnameVerifier(SSLSocketFactoryUtils.TrustAllHostnameVerifier())
|
||||
.connectTimeout(CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(WRITE_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.eventListenerFactory(WeakNetworkEventFactory.FACTORY)
|
||||
.build()
|
||||
.addInterceptor(HttpHeaderInterceptor())
|
||||
.addInterceptor(HttpPassportInterceptor())
|
||||
.addInterceptor(CronetInterceptor())
|
||||
.addInterceptor(HttpLoggingInterceptor())
|
||||
.sslSocketFactory(createSSLSocketFactory(), createTrustAllManager())
|
||||
.hostnameVerifier(SSLSocketFactoryUtils.TrustAllHostnameVerifier())
|
||||
.connectTimeout(CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(WRITE_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||
.eventListenerFactory(WeakNetworkEventFactory.FACTORY)
|
||||
.dispatcher(dispatcher)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,24 +36,24 @@ PASSWORD=xintai2018
|
||||
RELEASE=true
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.4.7.29
|
||||
MOGO_UTILS_VERSION=1.4.7.30
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.4.7.29
|
||||
MOGO_NETWORK_VERSION=1.4.7.30
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.4.7.29
|
||||
MOGO_PASSPORT_VERSION=1.4.7.30
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.4.7.29
|
||||
MOGO_SOCKET_VERSION=1.4.7.30
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.4.7.29
|
||||
MOGO_REALTIME_VERSION=1.4.7.30
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.4.7.29
|
||||
MOGO_TANLU_VERSION=1.4.7.30
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.4.7.29
|
||||
MOGO_LIVE_VERSION=1.4.7.30
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.7.29
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.7.30
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.4.7.29
|
||||
MOGO_LOCATION_VERSION=1.4.7.30
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.4.7.29
|
||||
MOGO_TELEMATIC_VERSION=1.4.7.30
|
||||
# v2x
|
||||
MOGO_V2X_VERSION=1.4.7.29
|
||||
MOGO_V2X_VERSION=1.4.7.30
|
||||
|
||||
Reference in New Issue
Block a user