HttpConnection establishment taking too long process in Android.
<p>I am using a <code>Service</code> to get data in my <code>Activity</code> when I use local server it's performance is very good but using <code>HTTPS</code> connection its taking too much time to establish connection and getting response.Please help me to resolve this? </p>

<p>Here is my code.</p>

<pre><code>private static HttpClient getHttpClient() {

// if httpclient object is null
        if (mHttpClient == null) {
            mHttpClient = new DefaultHttpClient();
            final HttpParams params = mHttpClient.getParams();
            ClientConnectionManager mgr=mHttpClient.getConnectionManager();
            mHttpClient = new DefaultHttpClient(
                    new ThreadSafeClientConnManager(params,
                        mgr.getSchemeRegistry()), params);
            HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
            HttpConnectionParams.setSoTimeout(params, HTTP_SOCKET_TIME_OUT);

            ConnManagerParams.setTimeout(params, HTTP_TIMEOUT); 
        }
        return mHttpClient; // returns httpclient object
    }
</code></pre>

<p>//and execution</p>

<pre><code>HttpClient client = getHttpClient();
HttpGet request = new HttpGet();

try{
    request.setURI(new URI(url));
    response = client.execute(request);

    // if the response code is 200
    if (response.getStatusLine().getStatusCode() == 200) {
    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    StringBuffer sb = new StringBuffer("");
    String line = "";
    String NL = System.getProperty("line.separator");

    // Read the line and append to string builder up to line null
    while ((line = in.readLine()) != null) {
        sb.append(line + NL);
    }
    in.close();
     result = sb.toString();
}
</code></pre>
