如何防止我的 Shiny 应用程序在开源闪亮服务器中断开连接?

ZPe*_*Peh 9 r nginx shiny shiny-server

我正在使用 Ubuntu 和 NGINX 在开源闪亮服务器上运行 R闪亮应用程序。但是,由于某种原因,我的应用程序不断收到“与服务器断开连接”的消息,而且我似乎无法让它工作。这个闪亮的应用程序在我的本地运行得非常好。

我已经通过Shiny server session time out does not work中的以下建议尝试了 javascript 解决方法,但它似乎仍然不起作用。

还尝试将app_idle_timeoutapp_init_timeout设置为更长的持续时间,但无济于事。

这是我的 nginx 配置文件:

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;

    server_name some_ip_address;

    location / {
         proxy_pass http://localhost:3838/;
         proxy_redirect http://localhost:3838/ $scheme://$host/;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection $connection_upgrade;
         proxy_read_timeout 20d;
    }

}
Run Code Online (Sandbox Code Playgroud)

想知道我是否编辑闪亮的服务器或 nginx 配置文件来使其工作?但我知道只能在专业版本中延长超时,但我猜一定有一些可能的解决方法。

gre*_*g L 10

app_idle_timeout您可以通过在 Shiny Server 配置文件中设置为 0 来禁用 Shiny Server(开源或专业版)中的应用程序空闲超时。

例如,

location / {
    app_idle_timeout 0;
}
Run Code Online (Sandbox Code Playgroud)

https://docs.rstudio.com/shiny-server/#application-timeouts

app_idle_timeout -- 定义没有活动连接的 R 进程应保持打开状态的时间量(以秒为单位)。在最后一个连接与 R 进程断开连接后,该计时器将启动,在指定的秒数后,如果没有创建新连接,则 R 进程将被终止。app_idle_timeout 的默认值为 5 秒。