expo-community / expo-server-sdk-ruby

A Ruby library for sending push notifications with Expo's notification service
MIT License
95 stars 53 forks source link

Exponent::Push::UnknownError: Unknown error format: #<Typhoeus::Response... #39

Closed kevgrig closed 2 years ago

kevgrig commented 3 years ago

I know this is similar to issues #33, #37, and #38; however, it has slightly different symptoms (different top expo SDK stack frames, only sending a single message, etc.). The following shows my application debug log sending a single message to a single device (details removed for privacy), and expo-server-sdk-ruby throws Exponent::Push::UnknownError: Unknown error format: #<Typhoeus::Response:0x00007f0bf98a6248> from exponent-server-sdk.rb } process_response

Feb 09 22:45:04 web24 rails[3377]: [e3013c2e-16f0-47dc-a61d-78d33bb36db8] Notification.try_send_notification for identity 2194: [
                                                         [0] {
                                                                   :to => "ExponentPushToken[$REMOVED]",
                                                                 :body => "$SUBJECT",
                                                                :sound => "default",
                                                                :badge => 0,
                                                             :priority => "high",
                                                                 :data => {
                                                                              :identity => 2194,
                                                                 :notification_category => "$CATEGORY",
                                                                               :subject => "$SUBJECT"
                                                             }
                                                         }
                                                     ]
Feb 09 22:46:05 web24 rails[3377]: [e3013c2e-16f0-47dc-a61d-78d33bb36db8] ApplicationController.catchall: #<Exponent::Push::UnknownError: Unknown error format: #<Typhoeus::Response:0x00007f0bf98a6248>>
Feb 09 22:46:05 web24 rails[3377]: [e3013c2e-16f0-47dc-a61d-78d33bb36db8] ApplicationController.catchall exception details: #<Exponent::Push::UnknownError: Unknown error format: #<Typhoeus::Response:0x00007f0bf98a6248>
                                                             /var/www/html/app/vendor/bundle/ruby/2.6.0/gems/exponent-server-sdk-0.1.0/lib/exponent-server-sdk.rb:127:in `process_response'
                                                             /var/www/html/app/vendor/bundle/ruby/2.6.0/gems/exponent-server-sdk-0.1.0/lib/exponent-server-sdk.rb:63:in `send_messages'
                                                             /var/www/html/app/app/models/notification.rb:213:in `try_send_notification' [...]
kevgrig commented 3 years ago

Just adding a note here that this problem is intermittent; generally, notifications work.

I've updated my Gemfile as follows to bring in the extra diagnostics from PR #36 and when the problem is reproduced I'll add details to this issue.

#gem "exponent-server-sdk"
gem 'exponent-server-sdk', git: "https://github.com/aki77/expo-server-sdk-ruby.git", branch: "fix-unknown-error"
vandemberg commented 3 years ago

@kevgrig The same message error with me, but the notification is not delivered

kevgrig commented 3 years ago

@vandemberg I haven't seen it since but we're not pushing many notifications through. I updated my server code with the additional logging so as soon as it occurs again, I'll post the details here.

sindhu5353 commented 3 years ago

@kevgrig For me, the issue was the version. I had tokens one got tied with the older expo version and the other one with the new expo version. So, in my case, the unknown error seems to be like this Unknown error format: {"errors":[{"code":"PUSH_TOO_MANY_EXPERIENCE_IDS","message":"All push notification messages in the same request must be for the same project; check the details field to investigate conflicting tokens.","details":{"@project":["ExponentPushToken[token1]","ExponentPushToken[token2]","ExponentPushToken[token3]","ExponentPushToken[token4"],"@user1/project":["ExponentPushToken[userToken1]","ExponentPushToken[userToken2]"]},"isTransient":false}]}

I had to clear the device ids and re-registered them to make it work.

kevgrig commented 3 years ago

I've reproduced with additional debug and the error is an HTTP 504. So it seems to be a backend issue:

Oct 25 13:00:59 web53 rails[54425]: [1c29d553-92d1-42f7-b445-a072591a3311] handle_exception: [...]<Exponent::Push::UnknownError: Unknown error format: <html>#015#012<head><title>504 Gateway Time-out</title></head>#015#012<body>#015#012<center><h1>504 Gateway Time-out</h1></center>#015#012<hr><center>nginx</center>#015#012</body>#015#012</html>

kevgrig commented 3 years ago

Looks like a known issue and the frequency seems to have increased recently based on the dates of recent comments, so I guess I'll check for the 504 and put in retries: https://github.com/expo/expo/issues/6486

kevgrig commented 2 years ago

Response from expo development:

we recommend retrying on failure: https://docs.expo.dev/push-notifications/sending-notifications/#retry-on-failure

santucorephp commented 2 years ago

@kevgrig For me, the issue was the version. I had tokens one got tied with the older expo version and the other one with the new expo version. So, in my case, the unknown error seems to be like this Unknown error format: {"errors":[{"code":"PUSH_TOO_MANY_EXPERIENCE_IDS","message":"All push notification messages in the same request must be for the same project; check the details field to investigate conflicting tokens.","details":{"@project":["ExponentPushToken[token1]","ExponentPushToken[token2]","ExponentPushToken[token3]","ExponentPushToken[token4"],"@user1/project":["ExponentPushToken[userToken1]","ExponentPushToken[userToken2]"]},"isTransient":false}]}

I had to clear the device ids and re-registered them to make it work.

what have you done to fix this error? updated the version of the exponent-server-sdk gem or others.

kevgrig commented 2 years ago

@santucorephp

what have you done to fix this error? updated the version of the exponent-server-sdk gem or others.

You must add a retry. Expo development wrote, "we recommend retrying on failure: https://docs.expo.dev/push-notifications/sending-notifications/#retry-on-failure"