你好 @featheredtoast,我也对此很好奇。你的意思是,桌面端网页推送通知不依赖 GCM、FCM 或 APNs 等第三方中介,而是由你自己的端点(例如连接到 Redis 或其他服务)直接发送通知消息;而只有移动端推送通知才使用这类第三方中介?
简短回答:否。推送通知由浏览器自身的集成提供,因此不涉及任何第三方中介。
从技术上讲,存在一台服务器(位于某处,并非您的 Discourse 服务器)负责将消息传递到您的设备——我们的实现支持所有实现了 VAPID 的浏览器(https://blog.mozilla.org/services/2016/08/23/sending-vapid-identified-webpush-notifications-via-mozillas-push-service/)。浏览器厂商的 VAPID 服务器才是真正将数据推送到您设备的服务器。
抱歉再次提起这个话题,但我的搜索将我引到了这里,我不确定这是否相关。
我们的 /logs 中充满了以下信息:
Failed to send push notification : host: fcm.googleapis.com, #<Net::HTTPForbidden 403 Forbidden readbody=true> body: the key in the authorization header does not correspond to the sender ID used to subscribe this user. Please ensure you are using the correct sender ID and server Key from the Firebase console.
Backtrace
webpush-1.1.0/lib/webpush/request.rb:175:in `verify_response'
webpush-1.1.0/lib/webpush/request.rb:34:in `perform'
webpush-1.1.0/lib/webpush.rb:44:in `payload_send'
/var/www/discourse/app/services/push_notification_pusher.rb:79:in `send_notification'
/var/www/discourse/app/services/push_notification_pusher.rb:25:in `block in push'
activerecord-6.0.3.3/lib/active_record/relation/delegation.rb:87:in `each'
activerecord-6.0.3.3/lib/active_record/relation/delegation.rb:87:in `each'
/var/www/discourse/app/services/push_notification_pusher.rb:23:in `push'
/var/www/discourse/app/jobs/regular/send_push_notification.rb:7:in `execute'
/var/www/discourse/app/jobs/base.rb:232:in `block (2 levels) in perform'
rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:76:in `with_connection'
/var/www/discourse/app/jobs/base.rb:221:in `block in perform'
/var/www/discourse/app/jobs/base.rb:217:in `each'
/var/www/discourse/app/jobs/base.rb:217:in `perform'
sidekiq-6.1.2/lib/sidekiq/processor.rb:196:in `execute_job'
sidekiq-6.1.2/lib/sidekiq/processor.rb:164:in `block (2 levels) in process'
sidekiq-6.1.2/lib/sidekiq/middleware/chain.rb:138:in `block in invoke'
/var/www/discourse/lib/sidekiq/pausable.rb:138:in `call'
sidekiq-6.1.2/lib/sidekiq/middleware/chain.rb:140:in `block in invoke'
sidekiq-6.1.2/lib/sidekiq/middleware/chain.rb:143:in `invoke'
sidekiq-6.1.2/lib/sidekiq/processor.rb:163:in `block in process'
sidekiq-6.1.2/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'
sidekiq-6.1.2/lib/sidekiq/job_retry.rb:111:in `local'
sidekiq-6.1.2/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'
sidekiq-6.1.2/lib/sidekiq.rb:38:in `block in <module:Sidekiq>'
sidekiq-6.1.2/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'
sidekiq-6.1.2/lib/sidekiq/processor.rb:257:in `stats'
sidekiq-6.1.2/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'
sidekiq-6.1.2/lib/sidekiq/job_logger.rb:13:in `call'
sidekiq-6.1.2/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'
sidekiq-6.1.2/lib/sidekiq/job_retry.rb:78:in `global'
sidekiq-6.1.2/lib/sidekiq/processor.rb:124:in `block in dispatch'
sidekiq-6.1.2/lib/sidekiq/logger.rb:10:in `with'
sidekiq-6.1.2/lib/sidekiq/job_logger.rb:33:in `prepare'
sidekiq-6.1.2/lib/sidekiq/processor.rb:123:in `dispatch'
sidekiq-6.1.2/lib/sidekiq/processor.rb:162:in `process'
sidekiq-6.1.2/lib/sidekiq/processor.rb:78:in `process_one'
sidekiq-6.1.2/lib/sidekiq/processor.rb:68:in `run'
sidekiq-6.1.2/lib/sidekiq/util.rb:15:in `watchdog'
sidekiq-6.1.2/lib/sidekiq/util.rb:24:in `block in safe_thread'
我们看到了成千上万条这样的错误。这……正常吗?
这听起来像是一个 bug。发送者 ID 不匹配时,应自动取消该客户端的订阅,但似乎是在检测来自 FCM 的错误消息时出现了问题。
这肯定不是面向客户端的问题,但确实存在本不该出现的噪音。
我想我们应该通过取消订阅来处理 Webpush::InvalidSubscription 和 Webpush::Unauthorized 异常。看来在我们上次更新推送通知的 错误处理 时,这些异常还不存在。
