josh
July 3, 2018, 12:56pm
2
There is some thinking that there are some issues in httpuv
and the RStudio IDE at play here.
I am trying to get to the bottom of what combination is expected to work.
opened 10:29PM - 07 Jun 18 UTC
closed 08:52PM - 08 Jun 18 UTC
TL;DR: [This line](https://github.com/rstudio/rstudio/blob/415a39c1c7e7c03787d2b… 8d18fa36c73cd05dc53/src/cpp/server/ServerSessionProxy.cpp#L805) doesn't account for the fact that some browsers send `Connection: Upgrade` and others (Firefox) send `Connection: keep-alive, Upgrade`.
---
With the combination of httpuv 1.4.x, RStudio Server, and Firefox, running Shiny apps through the session proxy doesn't work. The problem is fixed if you change ANY of those three though (switching to older httpuv, OR RStudio Desktop, OR Chrome all fix it).
The problem is with the HTTP request that initiates a WebSocket connection, and specifically, with that request's Connection header. Chrome sends `Connection: Upgrade`, while Firefox sends `Connection: keep-alive, Upgrade`. RFC 6455 page 17 says:
> The request MUST contain a |Connection| header field whose value MUST include the "Upgrade" token.
so both browsers are passing legal values.
However, RStudio Server's [proxy logic assumes](https://github.com/rstudio/rstudio/blob/415a39c1c7e7c03787d2b8d18fa36c73cd05dc53/src/cpp/server/ServerSessionProxy.cpp#L805) that the incoming request's Connection header must be equal to "Upgrade" to be considered an upgrade, and if it is not, it changes the header to `Connection: close` before sending upstream to httpuv.
httpuv <1.4 doesn't care if `Connection: close`, it allows a websocket connection anyway. That's why it can work with either Firefox or Chrome. But httpuv 1.4.x looks for `Connection: Upgrade`, so it doesn't work with Firefox.
### System details
RStudio Edition : Server
RStudio Version : 1.2.704 and 1.1.453
OS Version : Ubuntu 16.04
R Version : 3.4? Doesn't matter
### Steps to reproduce the problem
1. Use Firefox (must be Firefox) to log into RStudio Server
1. Install Shiny from CRAN (httpuv 1.4.0 or higher must be used)
2. Start a Shiny app, e.g. `shiny::runExample("01_hello")`, and let new browser window launch
### Describe the problem in detail
The app's page goes grey immediately
### Describe the behavior you expected
The app should work correctly
(cc @wch)
rstudio:master
← rstudio:bugfix/connection-upgrade
opened 05:29PM - 08 Jun 18 UTC
There were several places where we expected the websocket connection upgrade hea… der `Connection` to have the exact value `Upgrade`.
The standard, however, requires only that the header *include* the token `Upgrade`, and Firefox includes other values in the header (see #2940 for @jcheng5 's explanation of why this is a problem).
This change brings the implementation in line with the standard.
Fixes #2940.
rstudio:master
← rstudio:joe/bugfix/websocket-connection-close
opened 07:45PM - 08 Jun 18 UTC
This is a workaround for https://github.com/rstudio/rstudio/issues/2940. It
sto… ps an erroneously sent "Connection: close" header from breaking an
otherwise legit websocket request.
### Testing notes
Log into an RStudio Server (rstudio.cloud doesn't count, maybe because they run through a proxy) using Firefox. Do `shiny::runExample("01_hello")`. If httpuv is 1.4.x, the app will launch but immediately disconnect without rendering output. (Older versions of httpuv don't have the problem.)