Abhinandan Satpute Abhinandan Satpute - 3 years ago 60
R Question

Network error triggering the download report(report generation) action in server.R twice

I have the

shiny application
deployed on the
Rshiny pro server
. The main aim of the application is to process the input
excel
files and produce the report in the form of
word document
which has couple of
tables
and around 15
graphs
rendered using the
ggplot
.

This application works perfect for the input excel files having less than approx.
3500-4500 rows
for around
10 metrics
.

Now, I am trying to process the excel file with around
4000-4500 rows
for around
20 metrics
. While processing this file, during report generation(
Rmarkdown
file processing) it's showing the
network error
on the
UI
only. Despite this error on the UI, in the back-end the report file is getting generated, but the generated report doesn't get downloaded. After this error, the report generation action is getting triggered automatically resulting in the generation of two reports which is again doesn't get downloaded.

So, from this observations, I came to the conclusion that on getting the
network error
, the
download report
(report generation and downloading) action is getting triggered again by the server.R.

Has anyone been through such strange situation? I am looking for guidance regarding the two problems here-


  1. What can be the reason of getting the
    network error
    sometime only?

  2. What is there, which is triggering the
    download report
    action twice?

  3. Is there any option to specify the max. session timeout period?


Answer Source

I have found answers to above questions and I have already answered it here.

Though I would like to quickly answer questions in above explained context.

  1. Reason for getting network error: User will be presented with the network error only if the computations(in this case report generation) doesn't get completed within the 45 seconds. This is because the http_keepalive_timeout parameter is not defined in the server configuration and the default value for http_keepalive_timeout parameter is 45 seconds.
  2. Why download report action was getting triggered twice? : It is because the user session with the server was getting terminated during the computations which were happening after clicking the Download action button . There is parameter called reconnect in the shiny server configuration which is enabled by default. When a user's connection to the server is interrupted, Shiny Server will offer them a dialog that allows them to reconnect to their existing Shiny session for 15 seconds. This implies that the server will keep the Shiny session active on the server for an extra 15 seconds after a user disconnects in case they reconnect. After the 15 seconds, the user's session will be reaped and they will be notified and offered an opportunity to refresh the page. If this setting is true, the server will immediately reap the session of any user who is disconnected. You can read about it in the shiny server documentation. reconnect
  3. Option to specify the max. session timeout period: Yes. There is a parameter called http_keepalive_timeout. It will allow you to specify the maximum session timeout period. You will need to add http_keepalive_timeout parameter to the shiny-server.conf at the top level with the timeout period you want in seconds as shown below.

    http_keepalive_timeout 120;

    Read more about http_keepalive_timeout here. enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download