rsessionshinyshiny-serverreconnect

User session is getting interrupted after approx. 45 seconds


I have the shiny application deployed on the Rshiny pro server(1.5.2).

Application does some heavy computations and generates the report without any problem if it gets completed before approximately 45 seconds.

If the computation and report generation goes beyond approximately 45 seconds, user's session / connection to the server is getting interrupted. Then automatically server is reconnecting the disconnected users almost immediately. After few seconds of re-connection the user session is getting reaped and user is presented with the notwork error.

From above observations we know that the reconnect flag is enabled at the server.

I need help to understand-

  1. Why the user session is getting interrupted around approximately 45 seconds every single time.
  2. How to prevent this session interruption? Is there any configuration at server or application side which will help me achieve uninterrupted session between user and server?

Solution

  • Well, after searching and trying out different options I was able to find the answers to my questions.

    1. The user session was getting interrupted around approximately 45 seconds every single time because the http_keepalive_timeout parameter was not defined in the server configuration and the default value for http_keepalive_timeout parameter is 45 seconds.
    2. To prevent the session from getting reaped before the report generation, I added the http_keepalive_timeout parameter to the shiny-server.conf at the top level and set it's value to 120 seconds as shown below.

      http_keepalive_timeout 120;

    You can set the http_keepalive_timeout value as per your wish. I set it to 120 as my application is taking around 100-110 seconds to generate the report.

    Reference: shiny server configuration enter image description here