当服务器部署到 App Engine 时,我从我的 Android 应用程序调用 servlet 时遇到问题。该调用在本地服务器上运行良好,但是当我部署它时,如果我为 httpclient 设置超时,调用只会挂起或抛出 SocketTimeoutException。目前我的 servlet 什么都不做(所以它不可能花费太多时间来完成它的工作)。
我正在使用的代码
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(SERVER_URL+"/fileupload");
InputStreamEntity reqEntity = new InputStreamEntity(stream, 1000);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
// file uploaded successfully!
Log.e("ok","resp "+response.getStatusLine().getStatusCode());
} else {
Log.e("runtime exp","couldn't handle req"+response.getStatusLine().getStatusCode());
throw new RuntimeException("server couldn't handle request");
}
我想知道的是什么可能使此代码在 localhost 上运行良好,但在服务器部署到 App Engine 时却不行。任何输入表示赞赏。谢谢