私は 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) {
}
}
}