gpt4 book ai didi

android - Retrofit2 SSLHandshakeException

转载 作者:太空宇宙 更新时间:2023-11-03 14:43:20 26 4
gpt4 key购买 nike

我使用 Retrofit2。添加服务器端 SSL 后请求不会执行。 onFailure 方法获取下一个 Throwable - javax.net.ssl.SSLHandshakeException: Connection closed by peer.

初始化改造:

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(InterfaceAPI.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();

最佳答案

OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
clientBuilder.connectTimeout(60, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).writeTimeout(60, TimeUnit.SECONDS);

client = clientBuilder.build();

然后用这个客户端进行改造

关于android - Retrofit2 SSLHandshakeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41347148/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com