如何防止闪亮的应用程序变灰? [英] How to prevent a shiny app from being grayed out?

查看:69
本文介绍了如何防止闪亮的应用程序变灰?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Heroku中托管了一个闪亮的应用程序.用户闲置55秒后,该应用将显示为灰色.这适用于Chrome和Safari. Edge工作正常. Heroku为此有一个默认超时,并且看起来无法使用R buildpack对其进行修改( https ://github.com/virtualstaticvoid/heroku-shiny-app ).

we have a shiny app hosted in Heroku. After 55 secs of user inactivity, the app will be grayed out. This is applicable for Chrome and Safari. Edge is working fine. Heroku have a default timeout for that, and it looks like it cannot be modified using the R buildpack (https://github.com/virtualstaticvoid/heroku-shiny-app).



    function ping() {
        if (!window.Shiny.shinyapp.isConnected()) {
            window.Shiny.shinyapp.reconnect();
        }
    }
    setInterval(ping, 2000);

我们嵌入下面的JS代码以使用WebSocket重新连接,但是会话数据丢失了.还有什么可以尝试的吗?

We embedded below JS code to reconnect using the WebSocket, but the session data is lost. Is there anything else we can try?

以下是有关我们应用的更多信息: R 3.4.4 闪亮的1.1.0

Here is more info about our app: R 3.4.4 Shiny 1.1.0

推荐答案

用户闲置55秒后,该应用将显示为灰色.

After 55 secs of user inactivity, the app will be grayed out.

我遇到了类似的问题,但是上下文有所不同(这是由于代理设置而导致的,并且我没有使用Heroku),所以我不知道我使用的解决方案是否适合您(我将其发布在这里)因为我的回复太长,无法发表评论.

I had a similar problem, but the context was different (this was due to proxy settings and I didn't use Heroku) so I don't know whether the solution I used is an option for you (I post it here because my reply is too long for a comment).

我只添加了以下几行:

  autoInvalidate <- reactiveTimer(10000)
  observe({
    autoInvalidate()
    cat(".")
  })

通过这种方式,每隔10秒就会在控制台上打印一个点,并且我的应用程序不再变灰(尽管这实际上不是用户活动").

In this way a dot is printed in the console by every passage of 10 secs and my app didn't gray out anymore (though this is not really a "user activity").

这篇关于如何防止闪亮的应用程序变灰?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆