colyseus / uWebSockets-express

Express API compatibility layer for uWebSockets.js
https://npmjs.com/package/uwebsockets-express
MIT License
56 stars 13 forks source link

request size did not match content length #26

Closed jaythakor-ai closed 1 year ago

jaythakor-ai commented 1 year ago

Description

I just replaced the express server with the uwebsocket-epxress. I am getting "request size did not match content length" for some of the our APIs. And those APIs are working fine with express. Anyone have chance to looked into it? It is blocking some of the priority Task. Thanks in advance :)

endel commented 1 year ago

Hi @jaythakor-ai, we need a reproduction scenario to investigate. Either as a test case, or as a full app example that reproduces the issue.

girishghoda commented 1 year ago

Here is the code. We are trying to load a test on post API from Jmeter. Issue occurred and its failed most of the APIs @endel

   var uWebSockets_js_1 = require("uWebSockets.js");
    var uwebsockets_express_1 = require("uwebsockets-express");
    var uwsApp = uWebSockets_js_1.App();
    var app = (0, uwebsockets_express_1.default)(uwsApp);

    var compression = require('compression');
    app.use(compression({ filter: shouldCompress }))
    function shouldCompress(req, res) {
      if (req.headers['x-no-compression']) {
        // don't compress responses with this request header
        return false
      }
      // fallback to standard filter function
      return compression.filter(req, res)
    }

    http.createServer(function (req, res) {
          app(req, res); /*loggerMod(req, res);*/
        });`

     app.listen(1880, function (err) {
          if (err) {
            log.error(log._("server.unable-to-listen", {  }));
          } else {
            // register routes
            app.get("/test_endpoint", function (req, res) {
              res.json({ hello: "world!" });
            });

    uwsApp.get('/internal_healthcheck', (res, req) => {
      res.writeStatus('200 OK').writeHeader('IsAlive', 'Yes').end('{"status":"active","time":"' + Date.now() + '"}');
    })

    app.get('/healthcheck', (req, res) => {
      res.setHeader('Content-Type', 'application/json');
      res.send('{"status":"active","time":"' + Date.now() + '"}');
    });

    app.post("/postAPI", auth.needsPermission("nodes.read"), (req, res)=> {
          //here get an error (not every time, sometimes), currently we are load test on this API with jmeter
    });
 }
jaythakor-ai commented 1 year ago

@endel Please note that this error only comes when the request payload size is big. In our case, payload size is 34 kb. The uwebsocket-express version we are using is 1.3.1.

jaythakor-ai commented 1 year ago

Hi @endel any updates on this?? We are block on it.

endel commented 1 year ago

Thanks for the pull-request.

jaythakor-ai commented 1 year ago

@endel Welcome!