我正在尝试从nodejs后端的存储桶中检索图像。 它可以访问存储桶,因为如果我更改存储桶名称,它会给我一个错误。 请求此终结点时控制台中的此错误为“ [HTTP / 2 504网关超时62150ms]
当端口设置为443时,出现此错误:
文件的存储方式为:bucketname / folderName / imageName.png
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/mydb', { useNewUrlParser: true, useUnifiedTopology: true });
mongoose.set('useCreateIndex', true);
mongoose.set('debug', true);
let db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {
console.log('connected');
let DocumentSchema = mongoose.Schema({ name: { type: String, unique: true } });
let Document = mongoose.model('Document', DocumentSchema, 'documents');
const docs = [{ name: 'd1' }, { name: 'd1' }, { name: 'd2' }, { name: 'd3' }];
Document.insertMany(docs, (err, docs) => {
if (err) {
console.log(err);
}
else {
console.log('Documents inserted', docs.length);
}
});
});
我希望结果会随图像流一起发送回浏览器,以便使图像显示在屏幕上。现在,它给了我一个504网关超时的问题。该图像为1.3mb,我的互联网连接速度至少为60mbps,因此我认为这不是因为它花了几秒钟才看到错误,因为它在等待时会先冻结。
*使用的版本是通过npm安装的最新版本 *环境名称 最新的Nodejs,最新的nginx。