Chamo ele dentro de um AsyncTask.
2013/10/22 Diogo Henrique <diogjp10@gmail.com>
Você está executando isso dentro de uma Thread fora da principal ?Já aumentou o Timeout ?--
2013/10/22 Diego Lopes Marques da Silva <diego.lopes@dce.ufpb.br>--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.
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.
--
Diego Lopes Marques
MSc. Candidate in Computer Science at PPgSC - UFRN
MSc. Candidate in Computer Science at PPgSC - UFRN
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.






0 comentários:
Postar um comentário