/logs에 푸시 알림 오류가 발생합니다

아래 오류가 /logs에 비교적 자주(하루에 수십 건에서 수백 건) 기록되고 있습니다. 그 외에는 푸시 알림과 관련이 있는 것 같지만, 정확히 무슨 일이 일어나고 있는지, 그리고 주의가 필요한지 잘 모르겠습니다. 이는 최신 stable 버전에서 발생하는 문제입니다.

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.0.0/lib/webpush/request.rb:165:in verify_response' webpush-1.0.0/lib/webpush/request.rb:32:in perform’
webpush-1.0.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.1/lib/active_record/relation/delegation.rb:87:in each’
activerecord-6.0.3.1/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.3.0/lib/rails_multisite/connection_management.rb:68: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.0.7/lib/sidekiq/processor.rb:196:in execute_job' sidekiq-6.0.7/lib/sidekiq/processor.rb:164:in block (2 levels) in process’
sidekiq-6.0.7/lib/sidekiq/middleware/chain.rb:138:in block in invoke' /var/www/discourse/lib/sidekiq/pausable.rb:138:in call’
sidekiq-6.0.7/lib/sidekiq/middleware/chain.rb:140:in block in invoke' sidekiq-6.0.7/lib/sidekiq/middleware/chain.rb:143:in invoke’
sidekiq-6.0.7/lib/sidekiq/processor.rb:163:in block in process' sidekiq-6.0.7/lib/sidekiq/processor.rb:136:in block (6 levels) in dispatch’
sidekiq-6.0.7/lib/sidekiq/job_retry.rb:111:in local' sidekiq-6.0.7/lib/sidekiq/processor.rb:135:in block (5 levels) in dispatch’
sidekiq-6.0.7/lib/sidekiq.rb:37:in block in <module:Sidekiq>' sidekiq-6.0.7/lib/sidekiq/processor.rb:131:in block (4 levels) in dispatch’
sidekiq-6.0.7/lib/sidekiq/processor.rb:257:in stats' sidekiq-6.0.7/lib/sidekiq/processor.rb:126:in block (3 levels) in dispatch’
sidekiq-6.0.7/lib/sidekiq/job_logger.rb:13:in call' sidekiq-6.0.7/lib/sidekiq/processor.rb:125:in block (2 levels) in dispatch’
sidekiq-6.0.7/lib/sidekiq/job_retry.rb:78:in global' sidekiq-6.0.7/lib/sidekiq/processor.rb:124:in block in dispatch’
sidekiq-6.0.7/lib/sidekiq/logger.rb:10:in with' sidekiq-6.0.7/lib/sidekiq/job_logger.rb:33:in prepare’
sidekiq-6.0.7/lib/sidekiq/processor.rb:123:in dispatch' sidekiq-6.0.7/lib/sidekiq/processor.rb:162:in process’
sidekiq-6.0.7/lib/sidekiq/processor.rb:78:in process_one' sidekiq-6.0.7/lib/sidekiq/processor.rb:68:in run’
sidekiq-6.0.7/lib/sidekiq/util.rb:15:in watchdog' sidekiq-6.0.7/lib/sidekiq/util.rb:24:in block in safe_thread’

여기서도 같은 문제가 발생합니다 :confused:

흥미로운 점은, Android에서 멤버들이 푸시 알림을 비활성화했다가 다시 활성화하면 며칠 동안은 정상적으로 작동하지만, 그 후에는 로그에 경고가 많이 발생하고 :arrow_down: 알림이 다시 작동하지 않는다는 것입니다.

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.

처음에는 2주 동안 잘 작동했는데, 재빌드(rebuild)를 한 후에는 다시 작동을 멈췄습니다. 그래서 재빌드 앱 프로세스가 이 문제의 원인이 아닌가 싶습니다. 관리자 화면에서 업그레이드를 진행하면 그 후에는 잘 작동합니다. 현재 안드로이드 푸시 알림을 수정할 수 있는 유일한 방법은 멤버가 기능을 비활성화했다가 다시 활성화하는 것입니다. 그리고 다음 재빌드까지 다시 잘 작동합니다.

재빌드가 이 문제를 일으키는 것이 가능한가요?

네, 우리 포럼에서도 같은 문제가 있었습니다. 앱을 재빌드할 때마다 푸시 알림이 작동하지 않았습니다. 하지만 지금은 포럼에서 해결된 것 같습니다. 세 번째로 재빌드했는데도 푸시 알림이 여전히 잘 작동하고 있습니다. :heart_eyes: 정확히 어떤 문제였는지는 모르겠지만, 수정해 주셔서 정말 감사합니다! :slightly_smiling_face: