Mhd.Wanous
Mhd.Wanous

Reputation: 53

R-Shiny script timeout behind a load-balancer

I am testing one Shiny script on an instance in GCP. The instance resides behind a load-balancer that serves as a front end with a static IP address and SSL certificate to secure connections. I configured the GCP instance as part of a backend service to which the load-balancer forwards the requests. The connection between the load-balancer and the instance is not secured!

The issue: accessing the Shiny script via the load-balancer works, but the web browser's screen gets grayed (time-out) on the client-side after a short time of initiating the connection!! When the browser screen grayed out, I have to start over!! If I try to access the Shiny script on the GCP instance directly (not through the load-balancer), the script works fine. I suppose that the problem is in the load-balancer, not the script.

I appreciate any help with this issue.

Upvotes: 2

Views: 605

Answers (1)

Anja F.
Anja F.

Reputation: 76

Context: Shiny uses a websocket (RFC 6455) for its constant client-server communication. If, for whatever reason, this websocket connection gets dicsonnected, the user experience is the described "greying out". Fortunately GCP supports websockets. However, it seems that your load balancer has an unexpected http time out value set.

Depending on what type of load balancer you are using (TCP, HTTPS) this can be configured differently. For their HTTPS offering:

The default value for the backend service timeout is 30 seconds. The full range of timeout values allowed is 1-2,147,483,647 seconds.

Consider increasing this timeout under any of these circumstances:

[...]

The connection is upgraded to a WebSocket.

Answer: You should be able to increase the timeout for your backend service with the help of this support document.

Mind you, depending on your configuration there could be more proxies involved which might complicate things.

Alternatively you can try to prevent any timeout by adding a heartbeat mechanism to the Shiny application. Some ways of doing this have been discussed in this issue on GitHub.

Upvotes: 4

Related Questions