我在我的应用程序中使用Picasso 2.5.2.它运行良好,但无法从第三方服务器之一加载图片.当我尝试从此站点加载图片时,我收到此错误:
java.net.UnknownServiceException: CLEARTEXT communication not enabled for client at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:98) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:196) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:132) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:101) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179) at okhttp3.RealCall.execute(RealCall.java:63) at com.jakewharton.picasso.OkHttp3Downloader.load(OkHttp3Downloader.java:136) at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:47) at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206) at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)
当我在浏览器中打开此图像时,它会成功加载.网址看起来像http://somesite.com/path/to/file/123456.jpg
.是毕加索的虫子吗?怎么解决?
是毕加索的虫子吗?
我不这么认为.OkHttp默认情况下似乎阻止非SSL通信.我几年没有使用OkHttp进行纯文本HTTP请求,但这是我在检查与该错误消息相关的代码时看到的内容.
怎么解决?
使用https
URL.
如果某个恶魔般的狂人威胁要炸毁一个小城市,除非你使用普通http
,请配置OkHttpClient
通过它Builder
,包括调用connectionSpecs()
以指示你愿意支持哪种HTTP连接.例如:
.connectionSpecs(Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT))
将允许"现代TLS"(不完全确定什么是合格的)和普通的HTTP.
然后,将它OkHttpClient
用于Picasso,以及使用OkHttp直接进行的任何操作.