List of usage examples for java.net ConnectException ConnectException
public ConnectException()
From source file:com.damytech.HttpConn.AsyncHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { // This is an additional layer of retry logic lifted from droid-fu // See: https://github.com/kaeppler/droid-fu/blob/master/src/main/java/com/github/droidfu/http/BetterHttpRequestBase.java boolean retry = true; IOException cause = null;/*from ww w. j a v a 2 s.co m*/ HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "can't resolve host"); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.roach.framework.http.AsyncHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { // This is an additional layer of retry logic lifted from droid-fu // See:/*from ww w. j a va 2 s . c om*/ // https://github.com/kaeppler/droid-fu/blob/master/src/main/java/com/github/droidfu/http/BetterHttpRequestBase.java boolean retry = true; IOException cause = null; HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "can't resolve host"); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions // causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.android.pchelper.http.AsyncHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { // This is an additional layer of retry logic lifted from droid-fu // See: https://github.com/kaeppler/droid-fu/blob/master/src/main/java/com/github/droidfu/http/BetterHttpRequestBase.java boolean retry = true; IOException cause = null;// ww w .j a va 2s . c o m HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendErrorMessage(AsyncHttpClient.HTTP_RESPONSE_UNKNOWNHOST, e); } return; } catch (SocketException e) { // Added to detect host unreachable if (responseHandler != null) { responseHandler.sendErrorMessage(AsyncHttpClient.HTTP_RESPONSE_SOCKETERROR, e); } return; } catch (SocketTimeoutException e) { if (responseHandler != null) { responseHandler.sendErrorMessage(AsyncHttpClient.HTTP_RESPONSE_TTIMEOUT, e); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.fihmi.tools.minet.MiHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { boolean retry = true; IOException cause = null;/* w w w .j av a 2s . co m*/ HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "?", request_tag); } return; } catch (SocketException e) { // Added to detect host unreachable if (responseHandler != null) { responseHandler.sendFailureMessage(e, "?", request_tag); } return; } catch (SocketTimeoutException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "", request_tag); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (Exception e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "?url?", request_tag); } return; } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.example.wechatsample.library.http.AsyncHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { // This is an additional layer of retry logic lifted from droid-fu // See:/* w w w. j ava 2 s . co m*/ // https://github.com/kaeppler/droid-fu/blob/master/src/main/java/com/github/droidfu/http/BetterHttpRequestBase.java boolean retry = true; IOException cause = null; HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "can't resolve host"); } return; } catch (SocketException e) { // Added to detect host unreachable if (responseHandler != null) { responseHandler.sendFailureMessage(e, "can't resolve host"); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions // causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.aspire.mandou.framework.http.BetterHttpRequestBase.java
@Override public BetterHttpResponse send() throws ConnectException { BetterHttpRequestRetryHandler retryHandler = new BetterHttpRequestRetryHandler(maxRetries); // tell HttpClient to user our own retry handler httpClient.setHttpRequestRetryHandler(retryHandler); HttpContext context = new BasicHttpContext(); // Grab a coffee now and lean back, I'm not good at explaining stuff. This code realizes // a second retry layer on top of HttpClient. Rationale: HttpClient.execute sometimes craps // out even *before* the HttpRequestRetryHandler set above is called, e.g. on a // "Network unreachable" SocketException, which can happen when failing over from Wi-Fi to // 3G or vice versa. Hence, we catch these exceptions, feed it through the same retry // decision method *again*, and align the execution count along the way. boolean retry = true; IOException cause = null;//from ww w .j a v a 2 s. co m while (retry) { try { return httpClient.execute(request, this, context); } catch (IOException e) { cause = e; retry = retryRequest(retryHandler, cause, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryRequest(retryHandler, cause, context); } finally { // if timeout was changed with this request using withTimeout(), reset it if (oldTimeout != BetterHttp.getSocketTimeout()) { BetterHttp.setSocketTimeout(oldTimeout); } } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.chuannuo.tangguo.net.TGHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { boolean retry = true; IOException cause = null;/*from ww w.j a va 2s.c om*/ HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, "?"); } return; } catch (SocketException e) { // Added to detect host unreachable if (responseHandler != null) { responseHandler.sendFailureMessage(e, "?"); } return; } catch (SocketTimeoutException e) { if (responseHandler != null) { responseHandler.sendFailureMessage(e, ""); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (Exception e) { retry = false; responseHandler.sendFailureMessage(e, "url?"); } } ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.DGSD.DGUtils.Http.BetterHttpRequestBase.java
public BetterHttpResponse send() throws ConnectException { BetterHttpRequestRetryHandler retryHandler = new BetterHttpRequestRetryHandler(maxRetries); // tell HttpClient to user our own retry handler httpClient.setHttpRequestRetryHandler(retryHandler); HttpContext context = new BasicHttpContext(); // Grab a coffee now and lean back, I'm not good at explaining stuff. This code realizes // a second retry layer on top of HttpClient. Rationale: HttpClient.execute sometimes craps // out even *before* the HttpRequestRetryHandler set above is called, e.g. on a // "Network unreachable" SocketException, which can happen when failing over from Wi-Fi to // 3G or vice versa. Hence, we catch these exceptions, feed it through the same retry // decision method *again*, and align the execution count along the way. boolean retry = true; IOException cause = null;/* w w w .java 2 s .co m*/ while (retry) { try { return httpClient.execute(request, this, context); } catch (IOException e) { cause = e; retry = retryRequest(retryHandler, cause, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryRequest(retryHandler, cause, context); } finally { // if timeout was changed with this request using withTimeout(), reset it if (oldTimeout != BetterHttp.getSocketTimeout()) { BetterHttp.setSocketTimeout(oldTimeout); } } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.github.droidfu.http.BetterHttpRequestBase.java
@Override public BetterHttpResponse send() throws ConnectException { BetterHttpRequestRetryHandler retryHandler = new BetterHttpRequestRetryHandler(maxRetries); // tell HttpClient to user our own retry handler httpClient.setHttpRequestRetryHandler(retryHandler); HttpContext context = new BasicHttpContext(); // Grab a coffee now and lean back, I'm not good at explaining stuff. // This code realizes // a second retry layer on top of HttpClient. Rationale: // HttpClient.execute sometimes craps // out even *before* the HttpRequestRetryHandler set above is called, // e.g. on a// w w w. j a va 2 s. c o m // "Network unreachable" SocketException, which can happen when failing // over from Wi-Fi to // 3G or vice versa. Hence, we catch these exceptions, feed it through // the same retry // decision method *again*, and align the execution count along the way. boolean retry = true; IOException cause = null; while (retry) { try { return httpClient.execute(request, this, context); } catch (IOException e) { cause = e; retry = retryRequest(retryHandler, cause, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions // causes // DefaultRequestExecutor to throw an NPE, see // http://code.google.com/p/android/issues/detail?id=5255 cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryRequest(retryHandler, cause, context); } finally { // if timeout was changed with this request using withTimeout(), // reset it if (oldTimeout != BetterHttp.getSocketTimeout()) { BetterHttp.setSocketTimeout(oldTimeout); } } } // no retries left, crap out with exception ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }
From source file:com.frand.easyandroid.http.FFHttpRequest.java
private void makeRequestWithRetries() throws ConnectException { boolean retry = true; IOException cause = null;/*w ww . j ava 2 s.co m*/ HttpRequestRetryHandler retryHandler = client.getHttpRequestRetryHandler(); while (retry) { try { makeRequest(); return; } catch (UnknownHostException e) { if (responseHandler != null) { responseHandler.sendFailureMsg(e, reqTag, reqUrl); } return; } catch (SocketException e) { if (responseHandler != null) { responseHandler.sendFailureMsg(e, reqTag, reqUrl); } return; } catch (SocketTimeoutException e) { if (responseHandler != null) { responseHandler.sendFailureMsg(e, reqTag, reqUrl); } return; } catch (IOException e) { cause = e; retry = retryHandler.retryRequest(cause, ++executionCount, context); } catch (NullPointerException e) { cause = new IOException("NPE in HttpClient" + e.getMessage()); retry = retryHandler.retryRequest(cause, ++executionCount, context); } } ConnectException ex = new ConnectException(); ex.initCause(cause); throw ex; }