【问题标题】:Session times out after 5 minutes, even though the session-timeout parameter is set to 30会话在 5 分钟后超时,即使 session-timeout 参数设置为 30
【发布时间】:2018-05-15 03:49:45
【问题描述】:

我有一个通过 Volley 向服务器发送请求的 android 应用:

        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 中搜索了五分钟的超时时间,但找不到任何东西。我还对服务器配置文件进行了 grep,查找 300000、300 和 600(以毫秒、秒和分钟为单位的五分钟)并且没有配置任何这些值。我错过了什么?我在这上面花了将近一个星期,但它已经有点老了。

【问题讨论】:

    标签: android servlets tomcat7 android-volley session-timeout


    【解决方案1】:

    五分钟超时来自 Apache 服务器,而不是 Tomcat。在我将 Apache httpd.conf 文件中的 Timeout 设置从 600 更改为 -1 后,我得到了我正在寻找的无限超时。

    【讨论】:

      猜你喜欢
      • 2011-10-18
      • 1970-01-01
      • 2021-01-03
      • 2017-09-17
      • 2013-04-19
      • 1970-01-01
      • 2011-09-22
      • 2012-10-03
      相关资源
      最近更新 更多