Android: Okhttp3: SocketTimeoutException: не удалось подключиться к dns / xx.xx.xx.xx (порт 443) - PullRequest
0 голосов
/ 06 апреля 2020

Я использую модификацию с okhttp3 для одного из моих системных приложений, установленных в / system / priv-app, вызывает SocketTimeoutException, тот же код, скопированный в простое новое приложение, и это прекрасно работает.

Код:

val okHttpClient = OkHttpClient.Builder()
                .addInterceptor(authenticationInterceptor)
                .retryOnConnectionFailure(true)
                .protocols(listOf(Protocol.HTTP_1_1))
                .connectTimeout(31, TimeUnit.SECONDS)
                .readTimeout(15, TimeUnit.SECONDS)
                .writeTimeout(15, TimeUnit.SECONDS).build()

При возникновении проблемы наблюдается сбой системного вызова ioctl

04-06 19: 46: 19.969 11148 11189 E ion: ошибка ioctl c0044901 с кодом -1: неверный аргумент

Трассировка стека

04-06 19:46:51.901  5461  5476 E JavaBinder: java.net.SocketTimeoutException: failed to connect to abc.xyz.com/xx.xx.xx.xx (port 443) from /192.168.43.28 (port 44658) after 31000ms
04-06 19:46:51.901  5461  5476 E JavaBinder:    at libcore.io.IoBridge.connectErrno(IoBridge.java:185)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at libcore.io.IoBridge.connect(IoBridge.java:129)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:137)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at java.net.Socket.connect(Socket.java:621)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.java:73)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:246)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:166)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
04-06 19:46:51.901  5461  5476 E JavaBinder:    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)

...