我在节点JS服务器上使用firebase的admin SDK。 我注意到,通常没有明显的原因,整批通知都会失败。在大多数情况下,它都能正常运行,并且突然跳了,连续20条通知之一显示超时。
完整的错误消息是:
{
code: "app/network-timeout",
message: "Error while making request: timeout of 10000ms exceeded."
}
我正在使用的代码总结为:
const admin = require('firebase-admin');
admin.initializeApp({
credential: [...],
databaseURL: 'https://[...].firebaseio.com'
});
const message = {
notification: {
title: "My title",
body: "My content"
},
token: token
}
admin.messaging().send(message)
.then((response) => {
// message sent with success (most of the time)
})
.catch((err) => {
// message error: timeout
})
我认为这可能与定价计划有关,因为我通常使用firebase的有限功能会遇到此类故障,但是消息在定价计划中显示为“免费”。无论如何,我都切换了火花以防万一,我将监视任何更改。
我找不到任何人报告此类问题,也找不到我为什么 Firebase Messaging 随机超时?
答案 0 :(得分:0)
该错误消息向我建议您的服务器暂时无法访问FCM服务器。就是说超过了10秒的超时时间。如果出现此错误消息,则应重试API以发送该消息。
有时确实会出现网络问题,并且服务器和Firebase之间可能存在许多不受控制的网络跃点。重试网络故障对于容错始终很重要。