title: NodeJs socket io server file upload stops uploading when file is larger than 12mb via nginx proxy
body: <p>I have a socket.io server that's used as a chat server, the frontend connects to the socket and emits messages.</p>
  <p>One part of it has the ability to upload a video file. So for example:</p>
  <pre><code>socket.emit(
      'sendFile',
      selectedFile.name,
      selectedFile.type,
      selectedFile // file from input field
  );
  </code></pre>
  <p>And the server listens:</p>
  <pre><code>const app = express();
  
      const server = http.createServer(app);
      server.listen(3001, () =&gt; console.log(&quot;PORT CONNECTED %d&quot;,port));
      const io = socket(server, {
          transports: ['websocket', 'polling'],
          allowUpgrades: true
      });
      
      ioSocket.on('sendFile',(name, type, fileData) =&gt; {
      
      })
  </code></pre>
  <p>This is just the basics of it. So i have no issue with it at all when i test a file of 12MB, it uploads fine and the sendFile callback continues and writes the file to disc etc</p>
  <p>When i then try to upload another video that's 20mb it just sits there forever uploading. When i check the network tab in the browser it seems to disconnect the socket and make a new connection and i have no idea why. It just seems to do this when the file is larger than 12mb.</p>
  <p>The socket runs through a nginx proxy:</p>
  <pre><code>server {
          listen 443 ssl;
          ssl_certificate /usr/local/etc/ssl/certs/live/example.com/fullchain.pem;
          ssl_certificate_key /usr/local/etc/ssl/certs/live/example.com/privkey.pem;
          ssl_session_timeout 10m;
          ssl_verify_client off;
          server_name chat.example.com;
          error_log /usr/share/nginx/logs/error-chat.log;
          access_log /usr/share/nginx/logs/access-chat.log;
          client_max_body_size 1024M;
          location / {
              proxy_next_upstream error timeout http_502;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
              proxy_next_upstream_tries 10;
              proxy_pass http://chat;
              proxy_send_timeout 330s;
              proxy_read_timeout 330s;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_ssl_session_reuse on;
              proxy_set_header Referer $host:$server_port;
              proxy_http_version 1.1;
              proxy_set_header X-XSS-Protection 1;
              proxy_set_header X-Content-Type-Options nosniff;
              proxy_set_header Referrer-Policy origin;
              proxy_set_header X-Frame-Options DENY;
              proxy_request_buffering off;
              proxy_redirect off;
  
          }
      }
  </code></pre>
  <p><strong>UPDATE</strong>
  When i watch the console in the browser with a 40mb file, it emits the message and seems to be uploading, but after around 20-30 seconds it creates a new socket connection and the original is left pending and never receives a response from the node server because the browser has changed to monitor the new connection. If i leave it running like this for a bit the file does seem to upload, so it seems to be the browser waiting for a response and isn't getting one quick enough</p>