0
votes

Bottom line: I can't explain why I am able to view Shiny apps hosted by Shiny Server, but the same Shiny apps "gray out" when launched from RStudio Server. Both are hosted on a CentOS 7 server running NGINX.

Background: I have always been able to launch apps from both RStudio Server and Shiny Server when my access is through a VM on the server itself. I couldn't view apps using either method through non-VM means until yesterday. After reading up on the common fixes for apps that "gray out," I managed to get Shiny Server working through NGINX. Here are the recommended blocks I added/modified in the /etc/nginx/nginx.conf file:

(before the server definition)

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

(inside the server definition)

location /rstudio/ {
    rewrite ^/rstudio/(.*)\$ /\$1 break;
    proxy_pass http://127.0.0.1:8787;
    proxy_redirect http://127.0.0.1:8787/ \$scheme://\$host/rstudio/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade \$http_upgrade;
    proxy_set_header Connection \$connection_upgrade;
    proxy_read_timeout 20d;
}
location /shiny/ {
    rewrite ^/shiny/(.*)\$ /\$1 break;
    proxy_pass http://127.0.0.1:3838;
    proxy_redirect http://127.0.0.1:3838/ \$scheme://\$host/shiny/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade \$http_upgrade;
    proxy_set_header Connection \$connection_upgrade;
    proxy_read_timeout 20d;
}

My understanding of the problem was that the websocket handshake was taking too long, so these edits extended the time allowed to complete the handshake.

Shiny Server now hosts apps I can view through NGINX handling, but I still get a "grayed out" app launching from RStudio Server with this error in Chrome's developer tools:

WebSocket connection to 'wss://my.domain.net/p/4448/websocket/' failed:
Error during WebSocket handshake: Unexpected response code: 400

This was the same type of error I used to have when Shiny Server was hosting the apps, but the changes noted above fixed the issue.

1

1 Answers

0
votes

The difference in behavior between how RStudio Server and Shiny Server treated the same Shiny app stemmed from how each program was launched in the first place. Both are installed on an enterprise system that was launching IP:8787 or IP:3838 for RStudio and Shiny, respectively. They were never impacted in the least by my NGINX configuration, so the treatment of websockets addressed in the nginx.conf file was not applied. Accessing RStudio Server through IP/rstudio instead of IP:8787 forced the NGINX-added websocket handling denoted in the original post. Now my apps are live through both RStudio Server and Shiny Server.