watson-developer-cloud / assistant-simple

A simple sample application demonstrating the Watson Assistant api.
https://assistant-simple.ng.bluemix.net/
Apache License 2.0
482 stars 1.14k forks source link

Error 413 (Payload Too Large) custom context variables #240

Closed huesoamz closed 5 years ago

huesoamz commented 5 years ago

We have a custom solution that send customs context variables to watson that we define on our custom backend, the problem its that the

This is the error:

PayloadTooLargeError: request entity too large<br> &nbsp; &nbsp;at readStream (/node_modules/body-parser/node_modules/raw-body/index.js:155:17)<br> &nbsp; &nbsp;at getRawBody (/node_modules/body-parser/node_modules/raw-body/index.js:108:12)<br> &nbsp; &nbsp;at read (/node_modules/body-parser/lib/read.js:77:3)<br> &nbsp; &nbsp;at jsonParser (/node_modules/body-parser/lib/types/json.js:134:5)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at trim_prefix (/node_modules/express/lib/router/index.js:317:13)<br> &nbsp; &nbsp;at /node_modules/express/lib/router/index.js:284:7<br> &nbsp; &nbsp;at Function.process_params (/node_modules/express/lib/router/index.js:335:12)<br> &nbsp; &nbsp;at next (/node_modules/express/lib/router/index.js:275:10)<br> &nbsp; &nbsp;at serveStatic (/node_modules/express/node_modules/serve-static/index.js:75:16)</pre>

What could be the correct solution? increse the limit on the body parser, like this?:

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

We are using the app.js by default without setting any limit

Oliver-I commented 5 years ago

@stevenpkg Can you advise.

stevenpkg commented 5 years ago

I do not have an answer for you, you will need to debug your own code, as this space is only for issues with demo code

germanattanasio commented 5 years ago

@huesoamz you need to increase the payload as you suggested above. I think the demo uses the default value which is 1mb.

germanattanasio commented 5 years ago

I'm closing this since it's not a problem with this demo