HTTP 연결을 사용 중이며 내 앱이 주기적으로 서버에 연결합니다. 특정 시점 이후에 서버에 연결할 수없고 모든 연결에 대해 예외가 발생합니다.서버에서 연결을 거부했습니다.
java.net.ConnectException; www.somedomain.com/xxx.xxx.xxx.x에 연결하지 못했습니다. (포트 80) : 실패 연결 : ENETUNREACH을 (네트워크에 연결할 수)
org.apache.http.conn.HttpHostConnectException, http://www.somedomain.com에 연결이
java.net.UnknownHostException 거부, 호스트를 확인할 수 없습니다 "를 www.somedomain .com ": 호스트 이름과 연결된 주소가 없습니다.
서버가 차단 될 수 있습니다. 어떤 지점. 왜 이런 일이 일어날 지 모릅니다. 앱을 다시 설치하면 연결이 여전히 차단됩니다.
편집 : 여기에 HTTP를 보내기위한 코드가
public String send() throws ClientProtocolException, IOException {
InputStream is = null;
DefaultHttpClient httpclient = null;
HttpResponse response = null;
try {
System.setProperty("http.keepAlive", "false");
httpclient = new DefaultHttpClient();
HttpProtocolParams.setUseExpectContinue(httpclient.getParams(), false);
HttpRequestRetryHandler retryHandler = new HttpRequestRetryHandler() {
public boolean retryRequest(IOException exception, int executionCount,
HttpContext context) {
// retry a max of 5 times
if(executionCount >= 5){
return false;
}
if(exception instanceof NoHttpResponseException){
return true;
} else if (exception instanceof ClientProtocolException){
return true;
}
return false;
}
};
httpclient.setHttpRequestRetryHandler(retryHandler);
String proxyHost = android.net.Proxy.getDefaultHost();
int proxyPort = android.net.Proxy.getDefaultPort();
// Set Proxy params of client, if they are not the standard
if (proxyHost != null && proxyPort > 0) {
HttpHost proxy = new HttpHost(proxyHost, proxyPort);
httpclient.getParams().setParameter(
ConnRoutePNames.DEFAULT_PROXY, proxy);
}
HttpPost httppost = new HttpPost(url);
httppost.setEntity(new UrlEncodedFormEntity(qData));
response = httpclient.execute(httppost);
is = response.getEntity().getContent();
return inputStreamToString(is);
} finally {
try {
if (is != null) {
is.close();
}
} catch (Throwable e) {
}
try {
if (response != null && response.getEntity() != null) {
response.getEntity().consumeContent();
}
} catch (Throwable e) {
}
try {
if (httpclient != null
&& httpclient.getConnectionManager() != null) {
httpclient.getConnectionManager().shutdown();
}
} catch (Throwable e) {
}
}
}
은 코드를 제공합니다. 당신도 서버 - 애플 리케이션을 개발합니까? – sschrass
@SatelliteSD 게시판을 업데이트했습니다. –
"호스트를 확인할 수 없습니다"www.somedomain.com ": 호스트 이름과 연결된 주소가 없습니다. DNS 문제와 유사합니다. – kabuko