Android https handshake terminated exception
Asked Answered
R

0

6

I'm getting this exception randomly when trying to make https request, sometimes it works and sometimes failed to make handshaking with this exception. And I'm trying with lollipop and marshmallow.

javax.net.ssl.SSLProtocolException: 
SSL handshake terminated: ssl=0x9d397c00: Failure in SSL library,  usually a protocol error
error:100c543e:SSL routines:ssl3_read_bytes:TLSV1_ALERT_INAPPROPRIATE_FALLBACK (external/boringssl/src/ssl/s3_pkt.c:972 0x9b0bb3e0:0x00000001)

Here's how I'm making the requests

URL url;
HttpURLConnection connection;
try {
    String serverUrl = "...";
    url = new URL(serverUrl);

    connection = (HttpURLConnection) url.openConnection();

    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

    int responseCode = connection.getResponseCode();
    if (responseCode == HttpURLConnection.HTTP_OK) {
        Log.i(TAG, "OK");
        Log.i(TAG, "response " + in.readLine());
    } else {
        Log.e(TAG, "Error " + responseCode);
    }

    in.close();
} catch (Exception e) {
    e.printStackTrace();
}
Rhinal answered 29/5, 2016 at 21:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.