s41*_*135 5 javascript node.js express elasticsearch
我已经尝试了此处列出的许多解决方案(增加内存限制、添加参数限制、将类型添加为“应用程序/json”)来修复此“请求实体太大”错误(它还返回 http 代码 413)。但他们似乎都没有让这个错误消失。
json 的当前大小范围可以从 200k 到 400k 实体。
这是当前的配置:
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())
Run Code Online (Sandbox Code Playgroud)
关于如何增加限制的任何想法?
更多信息
如果有帮助,这是完整的错误消息:
{ 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>'
}
Run Code Online (Sandbox Code Playgroud)
解决方案
该错误确实是由于 elasticsearch 上的错误配置而不是 nodejs。通过关注https://github.com/elastic/elasticsearch-js/issues/241并http.max_content_length: 500mb在elasticsearch.yml.
@ryanlutgen 还在此处提供了有关此错误的更多信息的链接。 https://github.com/elastic/elasticsearch/issues/2902
这个问题已被解决。感谢所有的投入!
如果你没有解决你的问题,bodyParser也有一个限制。你必须使用
app.use(bodyParser({limit: '4MB'}))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9239 次 |
| 最近记录: |