Shiny server disconnecting app after adding SSL and apache?

Viewed 141

I have a shiny app deployed on a virtual machine with the free version of shiny server. It works without any issues locally, and when accessed through the localhost (same intranet).

However, after adding Apache and an SSL certificate to be able to access to the app from anywhere is when some issues with disconnecting have appeared.

The app disconnects when it needs to do longer calculation (~ 1 minute long). However, before disconnecting it shows the result of that calculation, (in this case a plot with plotly).

I get these errors:

Firefox can’t establish a connection to the server at https://*****/websocket

Connection closed. Info: {"type":"close","code":4704,
"reason":"Protocol error handling message: Error: Discard position id too big","wasClean":true}

The log file on /var/log/shiny-service/.log does not show any errors: This is the last line: Please specify in ggplotly() or plot_ly(). A message that doesn't cause any error.

I have already tried everything I could find like:

Apache Configuration:

  1. keepAlive On
  2. MaxKeepAliveRequests 0

Shiny Server Configuration:

  1. app_init_timeout 300;
  2. app_idle_timeout 300;

I have no idea what else to try to solve this, and any help would be highly appreciated.

Edit

This is how the app looks after it disconnects, the plot has been generated, after a minute, however it still disconnects automatically. enter image description here

1 Answers

I believe you can remediate the problem by increasing the values of app_init_timeout and app_idle_timeout. Please see this SO thread and these related docs. Also see this (regarding the Apache MaxKeepAliveRequests option).

I would find the best values by trial and error, but based on other users comments it may need to be as high as 1800. I imagine the reason it works on your LAN is that the latency that way would be much lower.

Having said all that, if the time taken is so high then there's probably something in the app that needs to be recoded in some way or which relies on some data set that is too large. You can probably test this by reducing the size of the data sent to plot.ly or the scope of the calculations being computed then see if the problem goes away.

Related