【问题标题】:Google Pubsub subscriber that does a http PUSH to a cloud function (in same project or another project)对云功能执行 http PUSH 的 Google Pubsub 订阅者(在同一项目或另一个项目中)
【发布时间】:2018-09-16 17:24:24
【问题描述】:

是否可以在一个项目中设置一个 pubsub 主题/订阅者,该项目执行 http PUSH 到同一或另一个谷歌项目中的云功能?我知道有 PubSub 触发器,但是当 pubsub 主题位于另一个谷歌项目中时,这些触发器不起作用。好奇这是否可以通过订阅者 PUSH 实现。

错误如果我尝试创建它,我会收到此 pubsub 错误 INVALID_ARGUMENT。我不确定这是否是因为我需要注册端点 (https://cloud.google.com/pubsub/docs/push#other-endpoints)。但是感觉不对,因为当我创建一个函数时,URL 会自动提供给我,我可以通过 Postman 访问它。

我确实找到了这个链接 (GCP - Verify ownership of a cloud function https endpoint for a PubSub push) 并认为它与 url-verification 相关.. 只是想要一个确认:)

想法?我是否在某处遗漏了一些文档?

编辑:我认为这与 URL 验证以及使用 ../_ah/push-handlers/.. 路径有关。当我注册一个 PubSub 触发器时,该函数的传递类型仍然是 PUSH,但它是一个具有更多路径的编码 URL:https://{hash}-dot-{hash}.appspot.com/_ah/push-handlers/pubsub/projects/{project-id}/topics/prototype-contact-created?pubsub_trigger=true

【问题讨论】:

  • 控制面板仅显示 INVALID_ARGUMENT 但如果您使用 gcloud 命令行工具,您将收到错误“提供的 HTTP URL 未在订阅的父项目中注册 (url="https://us-central1-<project>.cloudfunctions.net/testPubSub/test-pubsub", project_id="<pid>").”所以这个错误是因为未验证的端点。

标签: google-cloud-platform google-cloud-functions


【解决方案1】:

这是我在这里得到的解决方案:https://github.com/googleapis/nodejs-pubsub/issues/118

您需要在您的 Google Cloud Console 上验证此网址,API & ServicesCredentials,然后是Domain Verification 标签。添加网址 您的云功能。你需要为每一个 一个。

然后,确保在 Search Console 中选择 META TAG 验证方法,并在 GET 请求上响应。

if (req.method === 'GET') {
      // mine is in a settings file but you can hardcode yours for testing purposes
      return res.send(`<html><head><meta name="google-site-verification" content="${settings.google.siteVerificationCode}" /></head><body></body></html>`)
}

【讨论】:

    猜你喜欢
    • 2020-08-13
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 2016-06-12
    • 2023-01-19
    • 1970-01-01
    • 2021-10-13
    • 2013-05-25
    相关资源
    最近更新 更多