Google Cloud Platform pub/sub - 消息未传送给订阅者

Google Cloud Platform pub/sub - messages aren't being being delivered to subscriber

我正在根据 google (https://developers.google.com/gmail/api/guides/push) 提供的指南为 gmail 设置推送通知。我想让我的节点应用程序使用 .watch() 注册客户端,然后在指定端点接收电子邮件,如文档中所述。

我创建了 pub/sub 主题,将 gmail 添加为发布者,添加了订阅者,并在我的节点应用程序中调用了 watch() 。 watch() returns 相应的 { historyId: xxxx, expiration: yyyy } 对象,根据 google 的文档,这意味着调用成功。

用于在后端接收电子邮件通知的处理程序:

export const receiveGmailEmail: RequestHandler = async (req, res) => {
  log('Received update from google!');
  log(JSON.stringify(req.body, null, 2));
  return res.status(200);
}

正在注册:

  const watchRes = await gmailClient.watch();
  log('====> Watch Response <=====');
  log(JSON.stringify(watchRes, null, 2));

显示它正在正确注册的服务器日志: ====> 观察响应 <===== { "historyId": "6560", "expiration":“1562025255689” }

我从未在我的节点应用程序的接收端点收到消息。根据服务器日志,发布消息时我实际上从未收到任何请求。问题似乎是我的消息未送达。我已通过 Stackdriver 监视器确认,当我向电子邮件地址发送电子邮件时,pub/sub 主题正在发布消息,但如果我在 Stackdriver 中查看订阅的详细信息,它显示未送达的消息数量越来越多。

关于为什么订阅中的消息一直未送达有什么想法吗?

原来这不是 Google pub/sub 问题。 Amazon Cloudfront 默认阻止 POST 个请求,因此我必须编辑缓存行为以启用 POST 个请求。 https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesAllowedHTTPMethods