我在 Amazon S3 的 NodeJS 模块中遇到以下错误:Knox
events.js:72
throw er; // Unhandled 'error' event
^
Error: socket hang up
at SecurePair.error (tls.js:934:23)
at CleartextStream.read [as _read] (tls.js:432:17)
at CleartextStream.Readable.read (_stream_readable.js:320:10)
at EncryptedStream.write [as _write] (tls.js:345:25)
at doWrite (_stream_writable.js:219:10)
at writeOrBuffer (_stream_writable.js:209:5)
at EncryptedStream.Writable.write (_stream_writable.js:180:11)
at write (_stream_readable.js:573:24)
at flow (_stream_readable.js:582:7)
at Socket.pipeOnReadable (_stream_readable.js:614:5)
at Socket.EventEmitter.emit (events.js:92:17)
启用后longjohn
,我可以说错误是在从 Amazon S3 显示图像的路径上。
exports.image = function(req, res) {
var type = req.params.type;
var id = req.params.id;
var file = req.params.file;
var url = '/' + type + '/' + id + '/' + file;
var data = '';
knoxClient.get(url).on('response', function(s3res) {
s3res.setEncoding('binary');
s3res.on('data', function(chunk){
data += chunk;
});
s3res.on('end', function() {
res.write(data, encoding='binary');
res.end();
});
}).end();
};
如何处理错误以使服务器不会崩溃?