OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: One or more Aliases claimed by another User - HttpClient - DefaultDispatcher - API rate limit exceeded

Open michael-winkler opened this issue 2 years ago • 15 comments

What happened?

See Logcat details:

[DefaultDispatcher-worker-3] HttpClient: PATCH RECEIVED JSON: {"errors":["API rate limit exceeded"],"limit":"Subscription/User Update Per Device"}
[DefaultDispatcher-worker-3] HttpClient: PATCH RECEIVED JSON: {"errors":[{"code":"user-2","title":"One or more Aliases claimed by another User","meta":{"external_id":"[email protected]"}}]}
[DefaultDispatcher-worker-4] HttpClient: POST RECEIVED JSON: 
[DefaultDispatcher-worker-7] HttpClient: PATCH RECEIVED JSON: {"errors":["API rate limit exceeded"],"limit":"Subscription/User Update Per Device"}

This happens only if you use onesignal android sdk 5.0.0. The warnings did not appear for below versions.

Steps to reproduce?

I think the problem is that it is possible that one user can have multiple subscriptions.
If a user got two devices then two subscriptions are possible.

But if thats the case then you will see the warnings inside logcat.

As second information I already did the migration which is described here:
https://documentation.onesignal.com/docs/generate-firebase-credentials

What did you expect to happen?

The warnings should not appear

OneSignal Android SDK version

5.0.0

Android version

13, 12, 11, 10, 9, 8, 7.1, 7.0, 6, 5.1, 5.0, 4.4, 4.3 or below

Specific Android models

All

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

michael-winkler avatar Sep 04 '23 05:09 michael-winkler

See issue https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/714

michael-winkler avatar Sep 04 '23 05:09 michael-winkler

I can confirm that the problem only occurs when one user has multiple devices. This scenario can indeed happen in reality. Therefore, the SDK should accommodate this case instead of continuously generating warnings in the logcat every 10 milliseconds. The multiple log entries can significantly drain the device's battery.

In my case, a new log entry was generated every 10 milliseconds without end.

michael-winkler avatar Sep 04 '23 07:09 michael-winkler

@michael-winkler thank you for reporting this! We're investigating and will get back to you as soon as possible.

jennantilla avatar Sep 06 '23 20:09 jennantilla

@jennantilla Is this also fixed in 5.0.2 ?

michael-winkler avatar Sep 26 '23 05:09 michael-winkler

im on 5.0.3 and still happening - can confirm if I delete the subscription to the other device, it then registers the other device

Munzey avatar Oct 13 '23 13:10 Munzey

Same as @Munzey, we got same issue with 5.0.0, 5.0.2 and 5.0.3

sarbyn avatar Oct 16 '23 12:10 sarbyn

Any updates here?

RogerBrusamarello avatar Nov 21 '23 20:11 RogerBrusamarello

Also happening for me on Android, is there any fixes for this?

JennyFieldings12 avatar Dec 29 '23 23:12 JennyFieldings12

Looks like the issue is resolved.

michael-winkler avatar May 22 '24 18:05 michael-winkler

@michael-winkler how?

zmnv avatar Jun 20 '24 15:06 zmnv

I did got this type of bug again.

michael-winkler avatar Jun 20 '24 16:06 michael-winkler

same issue here

andreuka avatar Jun 24 '24 09:06 andreuka

any updates..?

Yurockkk avatar Jun 25 '24 03:06 Yurockkk

@jkasten2 Can you take a look here? Thank you very much

michael-winkler avatar Jun 25 '24 04:06 michael-winkler

Recent versions of the SDKs batch networks calls pretty well, so you shouldn't be seeing rate limit errors. Can you share the logcat with timestamps showing the network calls and code to reproduce the issue?

jkasten2 avatar Jun 25 '24 04:06 jkasten2

@jkasten2 I Have sdk onesignal_flutter: ^5.2.0; I got this error W/OneSignal(17028): [DefaultDispatcher-worker-6] HttpClient: Got Response = PATCH - STATUS: 409 - Body: {"errors":[{"code":"user-2","title":"One or more Aliases claimed by another User","meta":{"external_id":"33"}}]}

I think this error occurs because the app is being reinstalled multiple times. Why don't merge all users that use the same external_id instead of showing this error? I have more than 15 Subscription they have same OneSignal ID and same external_id

HaniKhaledAli avatar Jul 01 '24 23:07 HaniKhaledAli

This user-2 error happens when it tries to upgrade the default anonymous User the SDK created to an identified User but it already exists. The SDK handles this response internally by using the existing User going forward.

In summary the SDK handles the error user-2 and should be continuing correctly.

The logcat will reflect this is it is continuing correctly, example logcat:

2024-07-09 17:27:29.752 27103-27139 OneSignal               com.onesignal.sdktest                D  [DefaultDispatcher-worker-1] HttpClient: Request Sent = PATCH https://api.onesignal.com/apps/{{APP_ID}}/users/by/onesignal_id/{{ONESIGNAL_ID}}/identity - Body: {"identity":{"external_id":"YOUR_EXTERNAL_ID"}} - Headers: Accept=[application/vnd.onesignal.v1+json], Content-Type=[application/json; charset=UTF-8], OneSignal-Install-Id=[9d8fb6a1-206e-4e55-9283-58ba2bf579d8], OneSignal-Subscription-Id=[UUID], SDK-Version=[onesignal/android/050117]
2024-07-09 17:27:29.913 27103-27139 OneSignal               com.onesignal.sdktest                D  [DefaultDispatcher-worker-1] HttpClient: Got Response = PATCH https://api.onesignal.com/apps/{{APP_ID}}/users/by/onesignal_id/ONESIGNAL_ID/identity - FAILED STATUS: 409
2024-07-09 17:27:29.913 27103-27139 OneSignal               com.onesignal.sdktest                W  [DefaultDispatcher-worker-1] HttpClient: Got Response = PATCH - STATUS: 409 - Body: {"errors":[{"code":"user-2","title":"One or more Aliases claimed by another User","meta":{"external_id":"YOUR_EXTERNAL_ID"}}]}
2024-07-09 17:27:29.913 27103-27144 OneSignal               com.onesignal.sdktest                D  [OpRepo] LoginUserOperationExecutor now handling 409 response with "code": "user-2" by switching to user with "external_id": "YOUR_EXTERNAL_ID"
2024-07-09 17:27:29.914 27103-27139 OneSignal               com.onesignal.sdktest                D  [DefaultDispatcher-worker-1] HttpClient: Request Sent = POST https://api.onesignal.com/apps/{{APP_ID}}/users - Body: {"identity":{"external_id":"YOUR_EXTERNAL_ID"},"subscriptions":[{"id":"SUBSCRIPTION_ID"}],"properties":{"timezone_id":"America\/New_York","language":"en"},"refresh_device_metadata":true} - Headers: Accept=[application/vnd.onesignal.v1+json], Content-Type=[application/json; charset=UTF-8], OneSignal-Install-Id=[9d8fb6a1-206e-4e55-9283-58ba2bf579d8], OneSignal-Subscription-Id=[UUID], SDK-Version=[onesignal/android/050117]
2024-07-09 17:27:30.189 27103-27139 OneSignal               com.onesignal.sdktest                D  [DefaultDispatcher-worker-1] HttpClient: Got Response = POST https://api.onesignal.com/apps/{{APP_ID}}/users - STATUS: 202 - B

jkasten2 avatar Jul 09 '24 21:07 jkasten2