From 9994400462fa41482f980673f6fd70545c8bdc70 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Fri, 16 Aug 2024 16:13:57 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=8CFix=E3=80=8D=201=E3=80=81=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E7=9B=AE=E5=89=8Dhttp=E7=9A=84=E5=B9=B6=E5=8F=91?= =?UTF-8?q?=E9=87=8F=E5=A4=AA=E5=A4=A7=E4=BA=86=EF=BC=8C=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E7=94=A8=E5=A2=9E=E5=8A=A0okhttp=E9=98=9F=E5=88=97=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=9D=A5=E8=A7=A3=E5=86=B3=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=202=E3=80=81TODO=EF=BC=9A=E9=95=BF?= =?UTF-8?q?=E6=9C=9F=E9=9C=80=E8=A6=81=E5=AF=B9=E7=8E=B0=E6=9C=89Http?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BF=9B=E8=A1=8C=E6=A2=B3=E7=90=86=E7=AE=A1?= =?UTF-8?q?=E6=8E=A7=EF=BC=8C=E5=AF=B9=E9=AB=98=E9=A2=91=E6=AC=A1=E7=9A=84?= =?UTF-8?q?http=E8=AF=B7=E6=B1=82=E8=BD=AC=E5=88=B0socket=E4=B8=AD?= =?UTF-8?q?=E5=81=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @梁利晖、@钟超 --- .../com/mogo/cloud/network/OkHttpFactory.kt | 30 ++++++++++++------- gradle.properties | 22 +++++++------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/foudations/mogo-network/src/main/java/com/mogo/cloud/network/OkHttpFactory.kt b/foudations/mogo-network/src/main/java/com/mogo/cloud/network/OkHttpFactory.kt index ab17f08..fe4342d 100644 --- a/foudations/mogo-network/src/main/java/com/mogo/cloud/network/OkHttpFactory.kt +++ b/foudations/mogo-network/src/main/java/com/mogo/cloud/network/OkHttpFactory.kt @@ -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() } diff --git a/gradle.properties b/gradle.properties index 4ad5d09..762e63c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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