okhttp

HTTP FAILED: java.io.IOException: unexpected end of stream exception while making https request

好久不见. 提交于 2021-02-16 20:05:02
问题 We are previously using http apis and now we have migrated to https, with same code we are facing the exception HTTP FAILED: java.io.IOException: unexpected end of stream (this is for some device and for some network calls). We are using the OkHttp and Retrofit from android app. Below is our code @Provides @ApplicationScope OkHttpClient provideOkHttpClientV2( HttpLoggingInterceptor logging, Interceptor headerInterceptor) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); //Removed

HTTP FAILED: java.io.IOException: unexpected end of stream exception while making https request

て烟熏妆下的殇ゞ 提交于 2021-02-16 20:04:23
问题 We are previously using http apis and now we have migrated to https, with same code we are facing the exception HTTP FAILED: java.io.IOException: unexpected end of stream (this is for some device and for some network calls). We are using the OkHttp and Retrofit from android app. Below is our code @Provides @ApplicationScope OkHttpClient provideOkHttpClientV2( HttpLoggingInterceptor logging, Interceptor headerInterceptor) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); //Removed

深入理解 Web 协议(二):系统了解 DNS 和 WebSocket

冷暖自知 提交于 2021-02-13 09:33:37
本文转载自 “Vivo 互联网技术”,已获授权。 本文系统性的讲述了 DNS 协议与 WebSocket 协议的重要细节。 一、DNS 1、Linux dig命令 我们首先通过 Linux 下的dig命令来了解一下 DNS 是怎么做域名解析的。我们首先输入命令: dig www .baidu .com 看下标注的红框,从左到右依次代表: 域名的名称 也就是服务器名称 网络类型, DNS 协议在设计的时候考虑到了其他网络类型,但是目前位置这个值还是写死的IN 你就理解成是互联网就可以了。这个值一般不变 标识域名对应何种类型的地址,A 就代表ip的地址。 这里可能有人会问了,这个域名的后面为啥还有个“.”?我们输入的明明是 www.baidu.com 不是 www.baidu.com. 啊 。 这里要提一下: 末尾的 . 代表的就是 根域名 ,每个域名都有根域名,所以通常我们会 省略它 。 根域名的下一级叫 顶级域名 ,比如我们熟知的.com与.net。 再下一级就是 次级域名 了,比如例子中的.baidu。这个次级域名只要你有钱是可以随便注册的。 最后这个 www ,这个代表 三级域名 。一般是用户在自己的域里面为服务器分配的名称。用户可以随便分他。 所以可以看出来这里的域名是 分级别 的。能弄明白这点就能搞清楚为什么DNS的查询过程是 分级查询 了。 我们可以利用dig

Have second okHTTP request wait for the first to finish Android

蹲街弑〆低调 提交于 2021-02-11 14:47:55
问题 I am trying to call and IMDb API 2 times, the first time it calls and gets the ID for that movie/show and the second time it uses that ID to get all the information about that movie/show, I also need that ID for another part of the app so that is why I am doing it this way. The problem is that the second call isn't waiting for the first call to be done. I think this is why the variables aren't updated when I am trying to use them. This is my onCreate method where all this is happening, I took

java.net.ConnectException after switching accesspoint using WifiNetworkSpecifier on Android 10

混江龙づ霸主 提交于 2021-02-10 21:30:26
问题 Unable to make connection after configuring wifi accespoint using WifiNetworkSpecifier, Below is the trace Caused by: java.net.ConnectException: failed to connect to /10.123.45.1 (port 443) from /:: (port 0) after 120000ms: connect failed: ENETUNREACH (Network is unreachable) at libcore.io.IoBridge.connect(IoBridge.java:143) at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390) at java.net

java.net.ConnectException after switching accesspoint using WifiNetworkSpecifier on Android 10

[亡魂溺海] 提交于 2021-02-10 21:26:08
问题 Unable to make connection after configuring wifi accespoint using WifiNetworkSpecifier, Below is the trace Caused by: java.net.ConnectException: failed to connect to /10.123.45.1 (port 443) from /:: (port 0) after 120000ms: connect failed: ENETUNREACH (Network is unreachable) at libcore.io.IoBridge.connect(IoBridge.java:143) at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390) at java.net

java.net.ConnectException after switching accesspoint using WifiNetworkSpecifier on Android 10

孤人 提交于 2021-02-10 21:16:54
问题 Unable to make connection after configuring wifi accespoint using WifiNetworkSpecifier, Below is the trace Caused by: java.net.ConnectException: failed to connect to /10.123.45.1 (port 443) from /:: (port 0) after 120000ms: connect failed: ENETUNREACH (Network is unreachable) at libcore.io.IoBridge.connect(IoBridge.java:143) at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390) at java.net

OkHttp keeps getting StreamResetException: stream was reset: INTERNAL_ERROR when it's 200

你离开我真会死。 提交于 2021-02-10 16:23:58
问题 I got StreamResetException: stream was reset: INTERNAL_ERROR from OkHttp. What's the problem? Here's the logs. I/okhttp.OkHttpClient: <-- 200 https://www.example.com/user/list (396ms) I/okhttp.OkHttpClient: date: Fri, 04 Dec 2020 02:21:35 GMT I/okhttp.OkHttpClient: content-type: application/json I/okhttp.OkHttpClient: content-length: 99730 I/okhttp.OkHttpClient: server: nginx/1.18.0 I/okhttp.OkHttpClient: allow: GET, HEAD, OPTIONS I/okhttp.OkHttpClient: x-frame-options: DENY I/okhttp

OkHttp keeps getting StreamResetException: stream was reset: INTERNAL_ERROR when it's 200

微笑、不失礼 提交于 2021-02-10 16:22:18
问题 I got StreamResetException: stream was reset: INTERNAL_ERROR from OkHttp. What's the problem? Here's the logs. I/okhttp.OkHttpClient: <-- 200 https://www.example.com/user/list (396ms) I/okhttp.OkHttpClient: date: Fri, 04 Dec 2020 02:21:35 GMT I/okhttp.OkHttpClient: content-type: application/json I/okhttp.OkHttpClient: content-length: 99730 I/okhttp.OkHttpClient: server: nginx/1.18.0 I/okhttp.OkHttpClient: allow: GET, HEAD, OPTIONS I/okhttp.OkHttpClient: x-frame-options: DENY I/okhttp

How to get more than one Set-Cookie header from response using Retrofit/OkHttpClient?

。_饼干妹妹 提交于 2021-02-08 04:41:43
问题 I'm trying to make an authentication call using Retrofit/OkHttpClient on Android. The server responds a 302 with two Set-Cookie headers and okHttp handles redirection. I found some tips to get those cookies using cookieManager. But it seems cookieManager reads only one Set-Cookie header. I have this in server response headers: Set-Cookie:first=1 Set-Cookie:second=2 This is my cookieManager part: private static CookieManager cookieManager; (...) OkHttpClient okHttpClient = new OkHttpClient();