rstudio / shiny-server

Host Shiny applications over the web.
https://rstudio.com/shiny/server
Other
712 stars 291 forks source link

Sending huge data through custom message Error #545

Open Mush-A opened 1 year ago

Mush-A commented 1 year ago

Context

A shiny application I work on sends processed data through:

session$sendCustomMessage("handler", data)

The Javascript on the front end catches this message and does some visualizations:

Shiny.addCustomMessageHandler('handler', (data) => visualizer(data))

When the fetch data button is clicked this data is sent.

The shiny server is currently hosted on an Amazon EC2 R6a Large instance.

Issue

Depending on the parameters the user selects, the data can be small or huge. When the parameters are such that the data is a huge JSON object, there is an error given and the server disconnects with the following messages:

enter image description here

enter image description here

I have tested the same scenarios but without sending the data through session$sendCustomMessage("handler", data) and am not able to reproduce the error. It seems like sending a huge amount of data through the network causes the shiny server to disconnect.

This error does not occur locally with the same parameters in RStudio and only happens on the shiny server ec2 environment.

What could be the fix for this?

Mush-A commented 1 year ago

It seems like increasing the sockjs_heartbeat_delay and sockjs_disconnect_delay helped with this. After increasing this, the error seemed to be gone.

The connection simply times out when the huge data is loading and the comment above was correct about it.

https://docs.posit.co/shiny-server/

enter image description here

Simply add these directives in the shiny-server.conf with a reasonable value.