Home > Mobile >  Android 6.0 okhttp agents set up proxy requests are error Host is unresolved
Android 6.0 okhttp agents set up proxy requests are error Host is unresolved

Time:10-07

Use okhttp3 as the framework, network request provide agents set up methods
The Proxy Proxy=new Proxy (Proxy) Type) SOCKS, new InetSocketAddress (" xx. Xx. Xx. X ", 1080));
MOkHttpClient=new OkHttpClient. Builder ()
The proxy (proxy)
In Android phones, 7.0 + simulator and real machine can access the server error
Only with Android 6.0 and Android 6.0.1 machine and emulator appear the following error:
Java.lang.RuntimeException:java.net.UnknownHostException: Host is unresolved: mall. ZDMT. IO
2 the IO. Reactivex. Internal. Util. ExceptionHelper. WrapOrThrow (ExceptionHelper. Java: 45)
3...
4 under Caused by:
5 java.net.UnknownHostException:Host is unresolved: xx, XXX. Xx
6 java.net.Socket.connect (893) Socket. Java:
7 okhttp3. Internal. Platform. The AndroidPlatform. ConnectSocket (AndroidPlatform. Java: 69)
8 okhttp3. Internal. Connection. RealConnection. ConnectSocket (RealConnection. Java: 238)
9 okhttp3. Internal. Connection. RealConnection. Connect (RealConnection. Java: 158)
10 okhttp3. Internal. Connection. StreamAllocation. FindConnection (StreamAllocation. Java: 256)
11 okhttp3. Internal. Connection. StreamAllocation. FindHealthyConnection (StreamAllocation. Java: 134)
12 okhttp3. Internal. Connection. StreamAllocation. NewStream (StreamAllocation. Java: 113)
13 okhttp3. Internal. Connection. ConnectInterceptor. Intercept (42 ConnectInterceptor. Java:)
14 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 147)
15 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 121)
16 okhttp3. Internal. Cache. CacheInterceptor. Intercept (CacheInterceptor. Java: 93)
17 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 147)
18 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 121)
19 okhttp3. Internal. HTTP. BridgeInterceptor. Intercept (BridgeInterceptor. Java: 93)
20 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 147)
21 okhttp3. Internal. HTTP. RetryAndFollowUpInterceptor. Intercept (RetryAndFollowUpInterceptor. Java: 125)
22 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 147)
23 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 121)
24 (LogInterceptor. Java: 67 www.example.utils.LogInterceptor.intercept
25 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 147)
26 okhttp3. Internal. HTTP. RealInterceptorChain. Proceed (RealInterceptorChain. Java: 121)
27 okhttp3. RealCall. GetResponseWithInterceptorChain (RealCall. Java: 200)
28 okhttp3. RealCall. Execute (RealCall. Java: 77)
29 retrofit2. OkHttpCall. Execute (OkHttpCall. Java: 180)
30 retrofit2. Adapter. Rxjava2. CallExecuteObservable. SubscribeActual (CallExecuteObservable. Java: 41)
31. IO reactivex. Observables. Subscribe (observables. Java: 12030)
32 IO. Reactivex. Internal. Operators. Observables. ObservableLift. SubscribeActual (ObservableLift. Java: 57)
33. IO reactivex. Observables. Subscribe (observables. Java: 12030)
34 IO. Reactivex. Internal. Operators. Observables. ObservableMap. SubscribeActual (ObservableMap. Java: 33)
35. IO reactivex. Observables. Subscribe (observables. Java: 12030)
36 IO. Reactivex. Observables. BlockingFirst (observables. Java: 4986)

Is the Android 6.0 to Android 7.0 this change? How to use the proxy on Android 6.0?

CodePudding user response:

The latest test use HttpURLConnection set agency, there is no problem, seems to be the reason okhttp
Proxy Proxy=new Proxy (Proxy) Type) SOCKS, new InetSocketAddress (" xx. Xx. Xx, xx, 1080));
URL the URL=new URL (" http://www.163.com ");
The connection url=(HttpURLConnection). The openConnection (proxy);
  • Related