javascriptramazon-ec2shinyshiny-server

Shiny server - Sending huge data through custom message Error


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.

What could be the fix for this?


Solution

  • 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.