gpt4 book ai didi

firebase - 为什么我无法通过Firebase Cloud函数将文档插入到我的Elasticsearch索引中?

转载 作者:行者123 更新时间:2023-12-03 01:31:07 24 4
gpt4 key购买 nike

我正在尝试通过Firebase Cloud Function将文档插入到我的Elasticsearch索引中,但我不断收到以下错误:

{ Error: Request Timeout after 30000ms
at
/user_code/node_modules/elasticsearch/src/lib/transport.js:355:15
at Timeout.<anonymous>
(/user_code/node_modules/elasticsearch/src/lib/transport.js:384:7)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
status: undefined,
displayName: 'RequestTimeout',
message: 'Request Timeout after 30000ms',
body: undefined }

但是,当我在本地服务器实例上运行相同的代码片段时,插入文档没有问题。
const client = new elasticsearch.Client({
hosts: ['http://******:**********@ipaddress:port']
});

client.index({
index: 'csv',
type: 'default',
body: {
message: 'hi'
}
})
.then(res => console.log(res))
.catch(err => console.log(err));

云功能如下:
const client = new elasticsearch.Client({
hosts: ['http://******:**********@ipaddress:port']
});

exports.createElasticEntry = functions.firestore
.document('listings/{listingId}')
.onCreate((snap, context) => {
client.index({
index: 'csv',
type: 'default',
body: {
message: 'hi'
}
})
.then(res => console.log(res))
.catch(err => console.log(err));
});

最佳答案

在Cloud Functions中,使用免费的Spark计划,您无法建立与Google未完全控制和管理的服务的传出连接。这是为了防止滥用。

如果要连接到外部服务,则需要升级到付费计划。

关于firebase - 为什么我无法通过Firebase Cloud函数将文档插入到我的Elasticsearch索引中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55914438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com