简体   繁体   English

玩! 框架调用延迟DOMContentLoaded

[英]Play! framework call delayed DOMContentLoaded

I have a Play! 我有戏! application running for a while and it seems to work fine. 应用程序运行了一段时间,并且看起来工作正常。 But every now and then, some calls to the server get delayed for no apparent reason. 但是,时不时地,对服务器的某些调用由于没有明显的原因而被延迟。 I have a simple "ping" endpoint that returns a "text/plain" response: "pong". 我有一个简单的“ ping”端点,该端点返回“文本/纯文本”响应:“ pong”。

def ping = Action {
  Ok("pong")
}

Most of the times this responds quickly. 在大多数情况下,这会迅速做出响应。 But sometimes the page hangs in white and after a minute and a half, the response is shown in the page. 但是有时页面会挂成白色,一分半钟后,页面上会显示响应。 After several attempts to reproduce I managed to record the network calls in Firefox's developer tools and I see that the call is fast as usual but the "DOMContentLoaded" event happens later: 经过几次尝试重现之后,我设法在Firefox的开发人员工具中记录了网络调用,并且看到调用像往常一样快,但是稍后会发生“ DOMContentLoaded”事件:

在此处输入图片说明

It happens randomly, but I managed to reproduce more often when I just started the PC or when using the Private Browsing. 它是随机发生的,但是当我刚启动PC或使用“私人浏览”时,我设法重现了更多频率。 I could reproduce both in the production environment and running locally. 我既可以在生产环境中复制,也可以在本地运行。

Edit: I found that the time that the server is waiting to respond is the idle timeout . 编辑:我发现服务器等待响应的idle timeoutidle timeout So, I could reduce the pain with this configuration: 因此,我可以使用以下配置减轻痛苦:

play {
  server {
    http {
      idleTimeout = 10 seconds
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM