Skip to content

http node cannot handle large files in post request #21

@adasilva70

Description

@adasilva70

This issue was originally reported by Bluemix customer via a support case.

http node cannot handle large files (it works fine in the non-Bluemix version of node-red).
I created a very simple flow:

  • http input node configured for POST and accepting files
  • empty function node
  • http response

then I tried to post a large file using curl:

curl -d "@failreq.json" -X POST http://adasilva-node-red.mybluemix.net/test

The file has about 220kb. I cloned this repo and tried to change the index.js file adding the following code:

 var maxApiRequestSize = settings.apiMaxLength || '5mb';
 app.use(bodyParser.json({limit:maxApiRequestSize}));
 app.use(bodyParser.urlencoded({limit:maxApiRequestSize,extended:true}));

but it did not help. Here is the error I am seeing:

2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT 30 Jan 23:00:55 - [warn] [http in:355828e2.d32798] Error: request entity too large
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at readStream (/home/vcap/app/node_modules/node-red/node_modules/raw-body/index.js:196:17)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at getRawBody (/home/vcap/app/node_modules/node-red/node_modules/raw-body/index.js:106:12)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at read (/home/vcap/app/node_modules/node-red/node_modules/body-parser/lib/read.js:76:3)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at urlencodedParser (/home/vcap/app/node_modules/node-red/node_modules/body-parser/lib/types/urlencoded.js:115:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at metricsHandler (/home/vcap/app/node_modules/node-red/nodes/core/io/21-httpin.js:215:59)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at httpMiddleware (/home/vcap/app/node_modules/node-red/nodes/core/io/21-httpin.js:207:59)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at cookieParser (/home/vcap/app/node_modules/cookie-parser/index.js:56:14)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Route.dispatch (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/route.js:112:3)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at /home/vcap/app/node_modules/node-red/node_modules/express/lib/router/index.js:281:22
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Function.process_params (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/index.js:335:12)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at next (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/index.js:275:10)
   2018-01-30T18:00:55.78-0500 [APP/PROC/WEB/0] OUT     at Layer.handle [as handle_request] (/home/vcap/app/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions