Shiny Server periodic ERR_CONTENT_LENGTH_MISMATCH behind firewall

441 views Asked by At

I've been banging my head against this problem for several days now and am really hoping for some direction to help solve. Since I don't know where the problem is originating it's difficult to know the best forum to ask for help. I am also working in parallel with my IT department to get assistance.

I'm hosting a Shiny server on an Ubuntu 16.04 LTS VM in a Microsoft Azure subscription. I've set up Apache to act as reverse proxy to host both rstudio server and shiny server through port 80 per instructions on the rstudio site. (My corporate firewall blocks traffic outside of port 80) Rstudio server works fine.

Problem: When running apps that allow the user to upload a file, frequently, but unpredictably the app will crash. It is more common to see the crash when uploading multiple files in one batch, but it will also happen when uploading a single small file (~20kb). I have uploaded as many as 90 files of similar size at once, sometimes with success. Happy to follow up on any specific requests for config settings. I'm hoping the following clues will jump out at someone to point me in the right direction. Thanks.

Clues to tracking down the source of the error:

  1. I only see the problem behind my corporate firewall. I can use the app with no issues from my home computer.
  2. I hosted the application at shinyapps.io and it works great even from behind the firewall. (So I interpret this to mean I should be able to configure this somehow)
  3. The included sample-apps, and any apps that do not require file upload work fine.
  4. When I spin up a new VM, install R, then Shiny, change the host port to 80 but leave everything else at default ... I still have the problem.
  5. I'm using an up to date version of Chrome and always when I load an app I get the following message, even when the app works. (I replaced my domain name with 'url')

    WebSocket connection to 'ws://url/Shiny/uploadtest/__sockjs__/n=CSo4tDHrGWR4JWQEg4/200/dcuryf1t/websocket' failed: A server must not mask any frames that it sends to the client.
    
    y.websocket                 @ sockjs-0.3.4.min.js:27
    
    y._try_next_protocol        @ sockjs-0.3.4.min.js:27
    
    y._didClose                     @ sockjs-0.3.4.min.js:27
    
    f._ir.onfinish                  @ sockjs-0.3.4.min.js:27
    
    f.emit                          @ sockjs-0.3.4.min.js:27
    
    f.onfinish                      @ sockjs-0.3.4.min.js:27
    
    f.emit                          @ sockjs-0.3.4.min.js:27
    
    g.xhr.onreadystatechange    @ sockjs-0.3.4.min.js:27
    
  6. Only when the app crashes I get the following error:

    POST http://url/Shiny/uploadtest/session/3bcb8bbc2126672cbc1901c18cfe9d15/upload/36076c87d14189a785e7ceb5?w= net::ERR_CONTENT_LENGTH_MISMATCH
    
    send                                               @    jquery.min.js:4
    
    ajax                                               @    jquery.min.js:4
    
    onFile                                  @input_binding_fileinput.js:92
    
    $run                                            @   file_processor.js:80
    
    (anonymous)                             @   file_processor.js:50
    
    (anonymous)                             @input_binding_fileinput.js:82
    
    (anonymous)                             @   shinyapp.js:610
    
    _sendMessagesToHandlers             @   shinyapp.js:521
    
    dispatchMessage                         @   shinyapp.js:507
    
    c.onmessage                             @   shinyapp.js:114
    
    _conn.onmessage                         @   shiny-server-client.min.js:1
    
    MultiplexClient._conn.onmessage         @   shiny-server-client.min.js:1
    
    BufferedResendConnection._handleMessage     @   shiny-server-client.min.js:1
    
    RobustConnection._handleMessage         @   shiny-server-client.min.js:1
    
    conn.(anonymous function)               @   shiny-server-client.min.js:2
    
    d.dispatchEvent                             @   sockjs-0.3.4.min.js:27
    
    y._dispatchMessage                      @   sockjs-0.3.4.min.js:27
    
    y._didMessage                               @   sockjs-0.3.4.min.js:27
    
    b.onmessage                             @   sockjs-0.3.4.min.js:27
    
    d.dispatchEvent                             @   sockjs-0.3.4.min.js:27
    
    c.xo.onchunk                                @   sockjs-0.3.4.min.js:27
    
    f.emit                                      @   sockjs-0.3.4.min.js:27
    
    g.xhr.onreadystatechange                @   sockjs-0.3.4.min.js:27
    
1

There are 1 answers

0
Bill nussbaumer On

It turns out our company firewall wasn't playing nice with Shiny over an http connection. We set up apache to serve a secure connection over TLS and everything now works fine.