简体   繁体   English

NodeJS Express请求实体太大

[英]NodeJS Express Request Entity Too Large

I've tried many solutions listed here (increasing of memory limit, adding parameterlimit, adding type as 'application/json') to fix this 'Request Entity too large' error (it also returns http code 413). 我尝试了此处列出的许多解决方案(增加内存限制,添加参数限制,将类型添加为“ application / json”)来修复此“请求实体太大”错误(它还会返回http代码413)。 But none of them seem to make this error go away. 但是他们似乎都没有使这个错误消失。

The current size of the json can range from 200k up to 400k entities. json的当前大小范围可以从200k到400k实体。

Here is the current configuration: 这是当前配置:

app.use( bodyParser.json({limit: "15360mb", type:'application/json'}) );      
app.use(bodyParser.urlencoded({
  limit: "15360mb",
  extended: true,
  parameterLimit:5000000,
  type:'application/json'
})); 
app.use(bodyParser())

Any ideas on how to increase the limit? 关于如何增加限额的任何想法?

More information 更多信息

This is the full error message if it helps: 如果有帮助,这是完整的错误消息:

    { Error: Request Entity Too Large
        at respond (/home/nodejs/server/node_modules/elasticsearch/src/lib/transport.js:307:15)
        at checkRespForFailure (/home/nodejs/server/node_modules/elasticsearch/src/lib/transport.js:266:7)
        at HttpConnector.<anonymous> (/home/nodejs/server/node_modules/elasticsearch/src/lib/connectors/http.js:159:7)
        at IncomingMessage.bound (/home/nodejs/server/node_modules/lodash/dist/lodash.js:729:21)
        at emitNone (events.js:111:20)
        at IncomingMessage.emit (events.js:208:7)
        at endReadableNT (_stream_readable.js:1056:12)
        at _combinedTickCallback (internal/process/next_tick.js:138:11)
        at process._tickCallback (internal/process/next_tick.js:180:9)
      status: 413,
      displayName: 'RequestEntityTooLarge',
      message: 'Request Entity Too Large',
      path: '/_bulk',
      query: {},
      body: '<large body here>'
}

Solution

The error was indeed due to wrong configuration on elasticsearch and not nodejs. 该错误确实是由于对Elasticsearch而不是nodejs的错误配置造成的。 Manage to fix this by following https://github.com/elastic/elasticsearch-js/issues/241 and setting http.max_content_length: 500mb in elasticsearch.yml . 管理由下面来解决这个https://github.com/elastic/elasticsearch-js/issues/241和设置http.max_content_length: 500mbelasticsearch.yml

@ryanlutgen also provided a link for more information about this error here. @ryanlutgen还在此处提供了有关此错误的更多信息的链接。 https://github.com/elastic/elasticsearch/issues/2902 https://github.com/elastic/elasticsearch/issues/2902

This issue has been fixed. 这个问题已被解决。 Thanks for all the input! 感谢所有的投入!

If You doesn't solve your issue, bodyParser also has a limit . 如果您不能解决问题,bodyParser也有一个limit You must use 您必须使用

app.use(bodyParser({limit: '4MB'}))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM