Troubleshooting Shiny applications in Posit/RStudio Connect

Follow

If you are seeing unexpected behavior with your Shiny apps in Posit/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 Posit/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 Posit Community

It is possible that an app may run well locally, but fail on Posit/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 Posit/RStudio Connect typically will manage package installations for you (see here), use of the Applications.External option in Posit/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
  • Working locally, you might place shared resources in a common directory outside of a project, and reference it with a relative path. This will not work on Posit Connect. This is because the primary target for a piece of content must be at the root level of its bundle, and content runs in a security sandbox. Paths beginning with ../ will not find the files they expect. See the user guide for more.

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

Performance

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.

Comments