Tecnologia do Blogger.
RSS

[androidbrasil-dev] Dúvida com org.apache.http.conn.ConnectTimeoutException: Connect to timed out

Pessoal,

Estou tento problema ao realizar um get(ou um post), pois sempre me retornar o erro:
"org.apache.http.conn.ConnectTimeoutException: Connect to timed out"

Alguém poderia me ajudar?

Obrigado.

public String getRequest(String url) {
        try {
            KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
            trustStore.load(null, null);
   
            SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
            sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
           
            HttpParams params = new BasicHttpParams();
           
            HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            registry.register(new Scheme("https", sf, 8443));

            ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
       
            HttpClient httpclient = new DefaultHttpClient(ccm, params);
           
            HttpGet httpget = new HttpGet(url);
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            return httpclient.execute(httpget, responseHandler);
        } catch (ClientProtocolException e) {
            Log.e(Constants.TAG, e.getMessage(), e);
        } catch (IOException e) {
            Log.e(Constants.TAG, e.getMessage(), e);
        } catch (Exception e) {
            Log.e(Constants.TAG, e.getMessage(), e);
        }
        return null;
    }


--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário