If you are seeing unexpected behavior with your Shiny apps in RStudio Connect, the following information may be helpful.
"Disconnected from server" messages
Whenever this happens, we'd recommend starting by checking the application logs and the browser console to see if there are any errors in your code. You can find more about application logs here, and a summary of how to open the browser console is here.
Even if there is no error in the application log or browser console, the problem may still lie within the application code. First, make sure that the app runs correctly locally, outside of RStudio Connect. If not, consult one of the many resources available online to assist you in debugging and optimizing your app, including our Debugging Shiny Applications article, and the RStudio Community.
It is possible that an app may run well locally, but fail on RStudio Connect. This could happen for a variety of reasons, including but not limited to:
- Missing packages or incorrect package versions on the server - while RStudio Connect typically will manage package installations for you (see here), use of the
Applications.Externaloption in RStudio Connect (see here) may require some additional management. If you are using this option, make sure that the server has the necessary packages installed for the code you're running, and that the versions match the versions you're running locally.
- Environment variables differ between your local setup and your server
- The application timeouts are not set correctly - see here for more
- Forgetting to close each database connection after loading in data (the connection limit may be hit)
- Making multiple long-running calls to a public API (the API request limit may be hit or time out)
- Sub-optimal application instance or worker provisioning (you may need to tweak your content runtime settings (see here).
Finally, note that applications may disconnect if there is no user interaction for too long, based on your Connection timeout setting. See here for more on this and how to configure it.
If you are seeing performance errors with your applications, we'd recommend tweaking the content runtime settings based on your needs. See our article here for more. You can also tweak these settings on a server level using the scheduler - see here.