Я работаю над приложением Android, которое подключается к удаленному API для получения дополнительных данных. Как раз на днях у меня отключился домашний WiFi, поэтому я решил использовать свою сотовую точку доступа на другом телефоне. Странно, но это вызвало странную ошибку в моем приложении.
11-09 21:25:14.400 28932-28971/nl.lukehouben.scoutdrinks W/System.err: javax.net.ssl.SSLException: SSL handshake aborted: ssl=0xbe09b0: I/O error during system call, Connection reset by peer
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:410)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:257)
at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:210)
at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:477)
11-09 21:25:14.410 28932-28971/nl.lukehouben.scoutdrinks W/System.err: at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:441)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:270)
at nl.lukehouben.scoutdrinks.LoginActivity$getNetworkResult.doInBackground(LoginActivity.java:96)
at nl.lukehouben.scoutdrinks.LoginActivity$getNetworkResult.doInBackground(LoginActivity.java:69)
11-09 21:25:14.420 28932-28971/nl.lukehouben.scoutdrinks W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-09 21:25:14.430 28932-28971/nl.lukehouben.scoutdrinks W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Эта ошибка не возникает, когда я подключаюсь к своему домашнему Wi-Fi или использую данные сотовой связи, она возникает только тогда, когда я подключен к мобильной точке доступа. Любой знает, что происходит и как это можно исправить. Мой сервер имеет действительный сертификат LetsEncrypt, а мое устройство разработки работает под управлением Android 4.0.4 (API 15).
Это мой код:
protected String doInBackground(String... strings) {
try {
url = new URL("my_link");
conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(10000);
InputStream inputStream = conn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line = bufferedReader.readLine();
return line;
}
catch(Exception e) {
e.printStackTrace();
}
}
РЕДАКТИРОВАТЬ: По рекомендации кого-то я сделал дамп Wireshark, содержащий трафик между моим сервером и устройством отладки. Может быть, это поможет пролить свет на проблему?
No. Time Source Destination Protocol Length Info
1 0.000000 192.168.43.142 89.40.13.226 TCP 66 27869 → 443 [SYN] Seq=0 Win=17520 Len=0 MSS=1460 WS=256 SACK_PERM=1
Frame 1: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 0, Len: 0
No. Time Source Destination Protocol Length Info
2 0.086557 89.40.13.226 192.168.43.142 TCP 66 443 → 27869 [SYN, ACK] Seq=0 Ack=1 Win=14600 Len=0 MSS=1300 SACK_PERM=1 WS=512
Frame 2: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 0, Ack: 1, Len: 0
No. Time Source Destination Protocol Length Info
3 0.086709 192.168.43.142 89.40.13.226 TCP 54 27869 → 443 [ACK] Seq=1 Ack=1 Win=17408 Len=0
Frame 3: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 1, Ack: 1, Len: 0
No. Time Source Destination Protocol Length Info
4 0.094828 192.168.43.142 89.40.13.226 TLSv1.2 571 Client Hello
Frame 4: 571 bytes on wire (4568 bits), 571 bytes captured (4568 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 1, Ack: 1, Len: 517
Secure Sockets Layer
TLSv1.2 Record Layer: Handshake Protocol: Client Hello
Content Type: Handshake (22)
Version: TLS 1.0 (0x0301)
Length: 512
Handshake Protocol: Client Hello
No. Time Source Destination Protocol Length Info
5 0.163546 89.40.13.226 192.168.43.142 TCP 54 443 → 27869 [ACK] Seq=1 Ack=518 Win=15872 Len=0
Frame 5: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 1, Ack: 518, Len: 0
No. Time Source Destination Protocol Length Info
6 0.164487 89.40.13.226 192.168.43.142 TLSv1.2 1354 Server Hello
Frame 6: 1354 bytes on wire (10832 bits), 1354 bytes captured (10832 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 1, Ack: 518, Len: 1300
Secure Sockets Layer
TLSv1.2 Record Layer: Handshake Protocol: Server Hello
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 109
Handshake Protocol: Server Hello
No. Time Source Destination Protocol Length Info
7 0.164693 89.40.13.226 192.168.43.142 TCP 1354 443 → 27869 [ACK] Seq=1301 Ack=518 Win=15872 Len=1300 [TCP segment of a reassembled PDU]
Frame 7: 1354 bytes on wire (10832 bits), 1354 bytes captured (10832 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 1301, Ack: 518, Len: 1300
No. Time Source Destination Protocol Length Info
8 0.164722 192.168.43.142 89.40.13.226 TCP 54 27869 → 443 [ACK] Seq=518 Ack=2601 Win=17408 Len=0
Frame 8: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 518, Ack: 2601, Len: 0
No. Time Source Destination Protocol Length Info
9 0.165717 89.40.13.226 192.168.43.142 TLSv1.2 487 Certificate, Server Key Exchange, Server Hello Done
Frame 9: 487 bytes on wire (3896 bits), 487 bytes captured (3896 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 2601, Ack: 518, Len: 433
[3 Reassembled TCP Segments (2572 bytes): #6(1186), #7(1300), #9(86)]
Secure Sockets Layer
TLSv1.2 Record Layer: Handshake Protocol: Certificate
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 2567
Handshake Protocol: Certificate
Secure Sockets Layer
TLSv1.2 Record Layer: Handshake Protocol: Server Key Exchange
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 333
Handshake Protocol: Server Key Exchange
TLSv1.2 Record Layer: Handshake Protocol: Server Hello Done
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 4
Handshake Protocol: Server Hello Done
No. Time Source Destination Protocol Length Info
10 0.168158 192.168.43.142 89.40.13.226 TLSv1.2 180 Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
Frame 10: 180 bytes on wire (1440 bits), 180 bytes captured (1440 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 518, Ack: 3034, Len: 126
Secure Sockets Layer
TLSv1.2 Record Layer: Handshake Protocol: Client Key Exchange
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 70
Handshake Protocol: Client Key Exchange
TLSv1.2 Record Layer: Change Cipher Spec Protocol: Change Cipher Spec
Content Type: Change Cipher Spec (20)
Version: TLS 1.2 (0x0303)
Length: 1
Change Cipher Spec Message
TLSv1.2 Record Layer: Handshake Protocol: Encrypted Handshake Message
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 40
Handshake Protocol: Encrypted Handshake Message
No. Time Source Destination Protocol Length Info
11 0.255375 89.40.13.226 192.168.43.142 TLSv1.2 105 Change Cipher Spec, Encrypted Handshake Message
Frame 11: 105 bytes on wire (840 bits), 105 bytes captured (840 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 3034, Ack: 644, Len: 51
Secure Sockets Layer
TLSv1.2 Record Layer: Change Cipher Spec Protocol: Change Cipher Spec
Content Type: Change Cipher Spec (20)
Version: TLS 1.2 (0x0303)
Length: 1
Change Cipher Spec Message
TLSv1.2 Record Layer: Handshake Protocol: Encrypted Handshake Message
Content Type: Handshake (22)
Version: TLS 1.2 (0x0303)
Length: 40
Handshake Protocol: Encrypted Handshake Message
No. Time Source Destination Protocol Length Info
12 0.255951 192.168.43.142 89.40.13.226 TLSv1.2 85 Encrypted Alert
Frame 12: 85 bytes on wire (680 bits), 85 bytes captured (680 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 644, Ack: 3085, Len: 31
Secure Sockets Layer
TLSv1.2 Record Layer: Encrypted Alert
Content Type: Alert (21)
Version: TLS 1.2 (0x0303)
Length: 26
Alert Message: Encrypted Alert
No. Time Source Destination Protocol Length Info
13 0.257712 192.168.43.142 89.40.13.226 TCP 54 27869 → 443 [FIN, ACK] Seq=675 Ack=3085 Win=16896 Len=0
Frame 13: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 675, Ack: 3085, Len: 0
No. Time Source Destination Protocol Length Info
14 0.322180 89.40.13.226 192.168.43.142 TCP 66 [TCP Dup ACK 11#1] 443 → 27869 [ACK] Seq=3085 Ack=644 Win=15872 Len=0 SLE=675 SRE=676
Frame 14: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 3085, Ack: 644, Len: 0
No. Time Source Destination Protocol Length Info
15 0.322181 89.40.13.226 192.168.43.142 TCP 54 443 → 27869 [ACK] Seq=3085 Ack=676 Win=15872 Len=0
Frame 15: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 3085, Ack: 676, Len: 0
No. Time Source Destination Protocol Length Info
16 0.323105 89.40.13.226 192.168.43.142 TCP 54 443 → 27869 [FIN, ACK] Seq=3085 Ack=676 Win=15872 Len=0
Frame 16: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66), Dst: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e)
Internet Protocol Version 4, Src: 89.40.13.226, Dst: 192.168.43.142
Transmission Control Protocol, Src Port: 443, Dst Port: 27869, Seq: 3085, Ack: 676, Len: 0
No. Time Source Destination Protocol Length Info
17 0.323206 192.168.43.142 89.40.13.226 TCP 54 27869 → 443 [ACK] Seq=676 Ack=3086 Win=16896 Len=0
Frame 17: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface 0
Ethernet II, Src: 3a:d3:b8:d8:4f:9e (3a:d3:b8:d8:4f:9e), Dst: HuaweiTe_86:6a:66 (b4:86:55:86:6a:66)
Internet Protocol Version 4, Src: 192.168.43.142, Dst: 89.40.13.226
Transmission Control Protocol, Src Port: 27869, Dst Port: 443, Seq: 676, Ack: 3086, Len: 0
Загрузить файл WireShark