-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request entity too large #1856
Comments
Do you have a json parser set up in the middleware.json or server.js? Thanks, Raymond Feng (rfeng@us.ibm.com) StrongLoop http://strongloop.com/ makes it easy to develop APIs http://strongloop.com/mobile-application-development/loopback/ in Node, plus get DevOps capabilities http://strongloop.com/node-js-performance/strongops/ like monitoring, debugging and clustering.
|
I did not alter any of those files. They look like this: server.js var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
console.log('Web server listening at: %s', baseUrl);
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
}); middleware.json {
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
}
},
"session": {},
"auth": {},
"parse": {},
"routes": {
"loopback#rest": {
"paths": [
"${restApiRoot}"
]
}
},
"files": {},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"loopback#errorHandler": {}
}
} |
@raymondfeng is there any news on this? |
Hey @BenjaminHorn , do you have an sample repo from which I can reproduce the issue? If I am not mistaken, you should be able to use a Node.js buffer object to transfer binary data instead of a string. I don't know your particular use case though. |
@richardpringle @raymondfeng After some investigation I found that the problem is the content type.
then it works. My client (ember) app sends
then the new limit has no effect. Setting the type wont fix it. I know that is not in the strongloop documentation, only in https://www.npmjs.com/package/body-parser#type-2 ...
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "50mb"
"type": "application/vnd.api+json"
},
... |
I believe this is an issue with loopback-component-jsonapi. Needs a quick fix. |
thanks @digitalsadhu that was the issue indeed. I made a PR. |
What's the fix on this? I am running loopback on Bluemix. I am getting the Request too large error using swagger js client. |
Also running into the same error |
+1 |
Have you adjusted the limit per https://loopback.io/doc/en/lb2/config.json.html? |
Hello, This is my config.json { |
I checked where the error message Request Entity Too Large occurs and it is in here: function readStream (stream, encoding, length, limit, callback) { // check the length and limit options. Does anybody know which configuration file this picks up the options for limit and length from? |
I found that the limit value is picked up from server.js |
Serpentinefire, Can you supply the code on server.js to fix this issue? |
If you're using bodyParser, |
I already have this on my server.js and I still get the error. `var bodyParser = require('body-parser'); app.use( bodyParser.json({limit: '50mb'}) ); |
I got it working by modifying values in
|
@tborja |
Hello mnvini, I did as you suggested and changed the limit parameter for the types on body-parser, but I am still getting the same entity too large error. My loopback database is Cloudand on Bluemix and I am using this connector: It seems that it is the cloudant server that is sending out the entity too large error.
"couch returned 413" I am sending to Cloudant webGL as part of the json msg since the loopback connector does not support cloudant attachments. I guess I will have to find out where to increase the entity limit in cloudant. Thanks for all your help guys. |
It seems that there is a 1MB limit in the Cloudant request. It is just weird that this limit is there without a way to change it. |
Changes in config.json doesn't working for me. But making changes in middleware.json resolve my issue. |
Thanks nirmal25990, but IBM confirmed that middleware.json fixes won't fix the issue because it is Cloudant that has a 1MB limit on it's entities. They suggest either using an attachment in Cloudant or use an ObjectStore. |
Thanks ketansp, your solution was enough for me |
Are there any caveats for increasing this limit? |
If you are hosting the server on NGINX try the following Modify NGINX Configuration File sudo nano /etc/nginx/nginx.conf client_max_body_size 100M; sudo service nginx restart |
@youngtk96 its works. tks so much |
@nirmal25990 your fix worked for me too :) |
Unless you override parse param in middleware.json, by using a body-parser, setting it in config.js will work. It does work for us. |
If I try to send a json to the server, which is about 220kb. (It contains a base64 coded image as a long string). I am getting the following error:
server/confing.json
The text was updated successfully, but these errors were encountered: