如何更改船长 maxTimeToBuffer 属性
how to change skipper maxTimeToBuffer attribute
我正在使用 skipper 和 skipper-azure 一次上传多个文件,如果我上传少量文件,假设一次上传 20 到 30 个,一切正常,但如果我上传更多文件,如 200 或 300我开始收到某些文件的以下错误,即仅针对两个或三个文件而不是所有文件。
An Upstream timed out before it was plugged into a receiver
在 sails>node_modules>skipper>Standalone>Upstream>Upstream.js 文件中有一个属性 maxTimeToBuffer
并且它的默认值为 4500
当我将其更改为10000
我的代码工作正常我测试了 100 多次。
我的问题是
- 此更改有何影响?
- 有什么地方可以覆盖这个配置而不是
更改它的主文件我不想让这个配置消失
每次更新。
提前感谢大家的帮助
在sails.js v0.12 中,属性 maxTimeToBuffer 是可自定义的属性,可以添加到config/http.js 文件中以覆盖默认值4500 毫秒,即在开始接收传入文件上传后等待任何给定的实时上游插入接收器的最大毫秒数。
要使用可自定义的属性,您必须首先取消对 require skipper 的直接调用的注释。
// bodyParser: require('skipper')({strict: true})
关于这次改动的影响,官方已经明确了documentation:
The maximum number of miliseconds to wait for any given live upstream to be plugged in to a receiver after it begins receiving an incoming file upload. Skipper pauses upstreams to allow custom code in your app's policies and controller actions to run (e.g. doing database lookups) before you "plug in" the incoming file uploads (e.g. req.file('avatar').upload(...)) into your desired upload target (local disk, S3, gridfs, etc). Incoming bytes are managed using a combination of buffering and TCP backpressure built in to Node.js streams. The max buffer time is a configurable layer of defense to protect against denial of service attacks that attempt to flood servers with pending file uploads. If the timeout is exceeded, an EMAXBUFFER error will fire. The best defense against these types of attacks is to plug incoming file uploads into receivers as early as possible at the top of your controller actions.
我遇到了同样的问题...您必须修改位于 config 文件夹中的 http.js 文件...您必须执行如下操作:
passportInit: require('passport').initialize(),
passportSession: require('passport').session(),
bodyParser: (function _configureBodyParser(){
var skipper = require('skipper');
var middlewareFn = skipper({
strict: true,
maxTimeToBuffer: 100000,
});
return middlewareFn;
})(),
order: [
'cookieParser',
'session',
'passportInit',
'passportSession',
'bodyParser',
'compress',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
]
}
我正在使用 skipper 和 skipper-azure 一次上传多个文件,如果我上传少量文件,假设一次上传 20 到 30 个,一切正常,但如果我上传更多文件,如 200 或 300我开始收到某些文件的以下错误,即仅针对两个或三个文件而不是所有文件。
An Upstream timed out before it was plugged into a receiver
在 sails>node_modules>skipper>Standalone>Upstream>Upstream.js 文件中有一个属性 maxTimeToBuffer
并且它的默认值为 4500
当我将其更改为10000
我的代码工作正常我测试了 100 多次。
我的问题是
- 此更改有何影响?
- 有什么地方可以覆盖这个配置而不是 更改它的主文件我不想让这个配置消失 每次更新。
提前感谢大家的帮助
在sails.js v0.12 中,属性 maxTimeToBuffer 是可自定义的属性,可以添加到config/http.js 文件中以覆盖默认值4500 毫秒,即在开始接收传入文件上传后等待任何给定的实时上游插入接收器的最大毫秒数。
要使用可自定义的属性,您必须首先取消对 require skipper 的直接调用的注释。
// bodyParser: require('skipper')({strict: true})
关于这次改动的影响,官方已经明确了documentation:
The maximum number of miliseconds to wait for any given live upstream to be plugged in to a receiver after it begins receiving an incoming file upload. Skipper pauses upstreams to allow custom code in your app's policies and controller actions to run (e.g. doing database lookups) before you "plug in" the incoming file uploads (e.g. req.file('avatar').upload(...)) into your desired upload target (local disk, S3, gridfs, etc). Incoming bytes are managed using a combination of buffering and TCP backpressure built in to Node.js streams. The max buffer time is a configurable layer of defense to protect against denial of service attacks that attempt to flood servers with pending file uploads. If the timeout is exceeded, an EMAXBUFFER error will fire. The best defense against these types of attacks is to plug incoming file uploads into receivers as early as possible at the top of your controller actions.
我遇到了同样的问题...您必须修改位于 config 文件夹中的 http.js 文件...您必须执行如下操作:
passportInit: require('passport').initialize(),
passportSession: require('passport').session(),
bodyParser: (function _configureBodyParser(){
var skipper = require('skipper');
var middlewareFn = skipper({
strict: true,
maxTimeToBuffer: 100000,
});
return middlewareFn;
})(),
order: [
'cookieParser',
'session',
'passportInit',
'passportSession',
'bodyParser',
'compress',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
]
}