【问题标题】:What happens to requests when tomcat stops当tomcat停止时请求会发生什么
【发布时间】:2012-06-24 15:42:06
【问题描述】:

当您以“正常”方式停止或重新启动 tomcat 时,正在处理的 http 请求会发生什么情况? 它们会被处理直到响应完成还是http线程被中断? 有没有办法配置优雅停止?

【问题讨论】:

    标签: http tomcat servlets request


    【解决方案1】:

    Tomcat 支持unloadDelay,它会等待配置的时间来卸载 servlet。

    这应该在context.xml中配置如下:

    <context unloadDelay="10000">
    

    参考资料:

    【讨论】:

    • 很好,出于好奇,这是否会导致 tomcat 拒绝新请求,同时仍允许 servlet 完成现有请求的处理?
    • 是否有关于它如何拒绝请求的文档?例如,它只是不允许 TCP 套接字连接还是将 RST 发送回客户端?
    • 它在 linux 下使用 对我有用,但只能使用大写字母 _C_ontext。
    • @user2081279 您将上述更改粘贴到哪里?在哪个文件中?我很迷惑。谢谢。
    • @mungaih pk 有几种可能性。一种是在 server.xml 中这样设置:,或者你可以在 context.xml 中这样设置:stackoverflow.com/questions/51675180/…
    【解决方案2】:

    它只是终止请求并断开请求-响应链接。你得到了..

    无法连接

      Browser can't establish a connection to the server at Host:port.
    
      The site could be temporarily unavailable or too busy. Try again in a few moments.
      If you are unable to load any pages, check your computer's network connection.
      If your computer or network is protected by a firewall or proxy, make sure that Browser is permitted to access the Web.
    

    这无法处理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-25
      • 2012-07-06
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多