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.
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:
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?
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/
Simply add these directives in the shiny-server.conf
with a reasonable value.