我有一个android应用程序,它通过Volley向服务器发送请求:
private void waitForForfeit(final String user_id, final String accessToken) {
String url = "";
RequestQueue queue = Volley.newRequestQueue(activity);
try {
url = "https://www.chiaramail.com:443/GameServer/GameServer?user_ID=" + URLEncoder.encode(user_id, "UTF-8") + "&token=" + URLEncoder.encode(accessToken, "UTF-8") + "&cmd=" + URLEncoder.encode("WAITFOR FORFEIT ", "UTF-8") + "&parms=" + URLEncoder.encode(user_id, "UTF-8");
} catch (UnsupportedEncodingException e) {
Toast.makeText(activity, getString(R.string.wait_forfeit_error) + e.getMessage(), Toast.LENGTH_LONG).show();
spinner.setVisibility(View.INVISIBLE);
waitForForfeit(user_id, accessToken);
}
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (!response.startsWith("41 ")) {
queue_builder.setMessage(getString(R.string.wait_forfeit_error) + " " + response);
queue_alert = queue_builder.create();
queue_alert.show();
} else {
forfeitAlert.show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
volleyError = error;
Toast.makeText(activity, getString(R.string.wait_forfeit_error) + volleyError.getMessage(), Toast.LENGTH_LONG).show();
waitForForfeit(user_id, accessToken);
}
});
stringRequest.setRetryPolicy(new DefaultRetryPolicy(
60*1000*60,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
// Add the request to the RequestQueue.
queue.add(stringRequest);
}我已经确认服务器正在正确地接收和处理请求。该请求被设计为仅在特定事件发生时返回(另一个应用程序发送一个请求,导致服务器返回"41“响应),并且运行正常。
问题是,如果第二个应用程序没有在5分钟内发送请求,那么第一个应用程序就会经历VolleyError。即使会话超时设置为30分钟,也是如此:
<session-config>
<session-timeout>
60
</session-timeout>
</session-config>这里有人知道为什么会发生这种事吗?我在Tomcat中搜索了五分钟的暂停时间,但什么也找不到。我还查看了服务器配置文件,查找了300000、300和600 (以毫秒、秒和分钟表示的5分钟),但没有配置任何这些值。我遗漏了什么?我在这上面花了将近一周的时间,它已经有点过时了。
https://stackoverflow.com/questions/47586623
复制相似问题