okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Request HTTPS is very slow on Android.

Open rayboot opened this issue 11 years ago • 1 comments

Every https request cast 2 min...

The code is like

        String serverAddress = "https://auth.timeface.cn/aliyun/sts";
        OkHttpClient httpClient = new OkHttpClient();

        if (serverAddress.contains("https")) {
            ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
                    .tlsVersions(TlsVersion.TLS_1_0)
                    .cipherSuites(CipherSuite.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA)
                    .supportsTlsExtensions(true)
                    .build();

            httpClient.setConnectionSpecs(Collections.singletonList(spec));
            httpClient.setHostnameVerifier(new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    return true;
                }
            });
            httpClient.setConnectTimeout(1, TimeUnit.HOURS);
        }

        Request request = new Request.Builder()
                .url(serverAddress)
                .get()
                .build();

        Response response = httpClient.newCall(request).execute();
        String responseStr = response.body().string();

Why? Something wrong about my usage?

rayboot avatar Oct 30 '15 08:10 rayboot

This question is better suited for StackOverflow. We use this tracker for bug reports and feature requests only.

swankjesse avatar Oct 30 '15 11:10 swankjesse