Closed kunalgharate closed 3 years ago
It seems to happen when the server returns 201 on
2021-06-24 15:15:39.600 9078-9078/com.mongodb.rchatapp D/REALM_JAVA: HTTP Request =
POST https://realm.mongodb.com/api/client/v2.0/auth/session
Accept: application/json
Authorization: XXXXXX
Content-Type: application/json;charset=utf-8
Which is a problem on our end.
A temporary work-around would be to log the user out, then doing a new login.
Hi @kunalgharate
Could your issue be related to this? https://github.com/realm/realm-core/pull/4747, I.e. is the user revoked?
(We haven't made a release yet with the above fix, but will do so next week)
@cmelchior : I am also facing a similar issue and this API is getting triggered multiple times
HTTP Request = POST https://realm.mongodb.com/api/client/v2.0/auth/session Accept: application/json Authorization: Bearer xxxxxxxx Content-Type: application/json;charset=utf-8
Project repo: https://github.com/mohit-sharma-87/RChatApp
Steps to reproduce :
This issue still persists in version 10.7.0! After logging in, the app works fine for while, but after roughly 30 minutes the app freezes completely with just a white screen showing. When Realm.getInstanceAsync is called, neither onSuccess nor onError are ever invoked. Guess it has something to do with refreshing the sync session, because prior to 1.5.0 that issue did not excist.
Latest version working for me is 10.4.0.
This issue still persists in version 10.7.0!
Same for me. Even with the new realm-core 11.1.1 the issue still persists..
Is there a known workaround? I would rather log the user out before the refreshing of accesstoken runs into an endless loop and freezes my app..
Trying to reproduce this right now. @mohit-sharma-87 Did you use an emulator or real device for your test?
I tried to reproduce this on an API 30 emulator by:
1) Opening app and sign up 2) Get to "No chat room" screen. 3) Go back to home-screen by clicking home (thus putting app in background) 4) Wait 20 minutes 5) Open app again. It seems to still work.
@mohit-sharma-87 @Trailqueen @qrft Could any of you try to reproduce your problem with RealmLog.setLevel(LogLevel.ALL)
set and report the log output here? My attempt is below.
The HTTP Request at the end is triggered every ten seconds in an endless loop.
D/REALM_SYNC: Realm sync client ([realm-core-11.1.1]) Supported protocol versions: 2-3 Platform: Android Linux 3.18.71-perf+ #1 SMP PREEMPT Wed Nov 21 20:18:21 IST 2018 aarch64 Build mode: Release Config param: max_open_files = 256 Config param: one_connection_per_session = true Config param: connect_timeout = 120000 ms Config param: connection_linger_time = 30000 ms Config param: ping_keepalive_period = 60000 ms Config param: pong_keepalive_timeout = 120000 ms Config param: fast_reconnect_limit = 60000 ms Config param: disable_upload_compaction = false Config param: tcp_no_delay = false Config param: disable_sync_to_disk = false User agent string: 'RealmSync/11.1.1 (Android Linux 3.18.71-perf+ #1 SMP PREEMPT Wed Nov 21 20:18:21 IST 2018 aarch64) RealmJava/10.7.0 (elsa, LG-H990, v26) Unknown' D/REALM_JNI: SyncClient thread created D/REALM_JAVA: HTTP Request = POST https://eu-central-1.aws.realm.mongodb.com/api/client/v2.0/auth/session Accept: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYWFzX2RhdGEiOm51bGwsImJhYXNfZGV2aWNlX2lkIjoiNjEwMjhkNDA4YzRjOGNjMmFiMTk5ODEzIiwiYmFhc19kb21haW5faWQiOiI2MDlhNGY1NjgyNGJiOTMyNmJkMWFiZTEiLCJiYWFzX2lkIjoiNjEwMjhkNDA4YzRjOGNjMmFiMTk5ODE0IiwiYmFhc19pZGVudGl0eSI6eyJpZCI6Imc1REF3N3hxTnFWc2xNRldTQm9BSG52SUdVbDEiLCJwcm92aWRlcl90eXBlIjoiY3VzdG9tLXRva2VuIiwicHJvdmlkZXJfaWQiOiI2MDlhNWViZDFhMzZlZGQxNjgyNmYzNDYifSwiZXhwIjoxNjMyNzQxMTg0LCJpYXQiOjE2Mjc1NTcxODQsInN0aXRjaF9kYXRhIjpudWxsLCJzdGl0Y2hfZGV2SWQiOiI2MTAyOGQ0MDhjNGM4Y2MyYWIxOTk4MTMiLCJzdGl0Y2hfZG9tYWluSWQiOiI2MDlhNGY1NjgyNGJiOTMyNmJkMWFiZTEiLCJzdGl0Y2hfaWQiOiI2MTAyOGQ0MDhjNGM4Y2MyYWIxOTk4MTQiLCJzdGl0Y2hfaWRlbnQiOnsiaWQiOiJnNURBdzd4cU5xVnNsTUZXU0JvQUhudklHVWwxIiwicHJvdmlkZXJfdHlwZSI6ImN1c3RvbS10b2tlbiIsInByb3ZpZGVyX2lkIjoiNjA5YTVlYmQxYTM2ZWRkMTY4MjZmMzQ2In0sInN1YiI6IjYwOWE1ZWZhMTQ4MGRkZjRhNjA1YzBiYyIsInR5cCI6InJlZnJlc2gifQ.FIui3g0Pf3HayVH4d77dJmtAhK8FU26Hwh4yLDTFkwA Content-Type: application/json;charset=utf-8
Trying to reproduce this right now. @mohit-sharma-87 Did you use an emulator or real device for your test?
I tried to reproduce this on an API 30 emulator by:
- Opening app and sign up
- Get to "No chat room" screen.
- Go back to home-screen by clicking home (thus putting app in background)
- Wait 20 minutes
- Open app again. It seems to still work.
@cmelchior : I did it with the emulator, let me try to replicate it again.
@cmelchior, we're facing a similar issue from v10.5.0 onwards. Downgrading to 10.4.0 fixes it for us.
Steps to reproduce:
I had posted a query on this on MongoDB community forum - link.
Realm Sync Logs:
D/REALM_SYNC: Realm sync client ([realm-core-11.0.2])
D/REALM_SYNC: Supported protocol versions: 2-3
D/REALM_SYNC: Platform: Android Linux XXXXX
D/REALM_SYNC: Build mode: Release
D/REALM_SYNC: Config param: max_open_files = 256
D/REALM_SYNC: Config param: one_connection_per_session = true
D/REALM_SYNC: Config param: connect_timeout = 120000 ms
D/REALM_SYNC: Config param: connection_linger_time = 30000 ms
D/REALM_SYNC: Config param: ping_keepalive_period = 60000 ms
D/REALM_SYNC: Config param: pong_keepalive_timeout = 120000 ms
D/REALM_SYNC: Config param: fast_reconnect_limit = 60000 ms
D/REALM_SYNC: Config param: disable_upload_compaction = false
D/REALM_SYNC: Config param: tcp_no_delay = false
D/REALM_SYNC: Config param: disable_sync_to_disk = false
D/REALM_SYNC: User agent string: 'RealmSync/XXXXX'
Realm Java Logs:
D/REALM_JAVA: Creating session for: XXXXX.realm
D/REALM_JAVA: First session created. Adding network listener.
D/REALM_JAVA: HTTP Request =
POST https://ap-south-1.aws.realm.mongodb.com/api/client/v2.0/auth/session
Accept: application/json
Authorization: Bearer XXXXX
Content-Type: application/json;charset=utf-8
D/REALM_JAVA: HTTP Request =
POST https://ap-south-1.aws.realm.mongodb.com/api/client/v2.0/auth/session
Accept: application/json
Authorization: Bearer XXXXX
Content-Type: application/json;charset=utf-8
((^ Repeated multiple times, in loop))
Additional Info:
We're using synced Realm with JWT auth. Issue is reproducible with both getInstance
and getInstanceAsync
.
Hi @kunalgharate
Could your issue be related to this? realm/realm-core#4747, I.e. is the user revoked?
(We haven't made a release yet with the above fix, but will do so next week)
Yes this is session issue i think token get expired when user is offline for more than 10 -20 mins
Trying to reproduce this right now. @mohit-sharma-87 Did you use an emulator or real device for your test?
I tried to reproduce this on an API 30 emulator by:
- Opening app and sign up
- Get to "No chat room" screen.
- Go back to home-screen by clicking home (thus putting app in background)
- Wait 20 minutes
- Open app again. It seems to still work.
try to wait some more time around 1 hour. Simply use the app offline for some time then close the app for 1 hour and then open the app.
I can reproduce this now. It is indeed refreshing the access token that fails with 400 Bad Request.... an example request is here:
POST https://realm.mongodb.com/api/client/v2.0/auth/session
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYWFzX2RhdGEiOm51bGwsImJhYXNfZGV2aWNlX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjYzIiwiYmFhc19kb21haW5faWQiOiI1ZmQ5ZWRlNjE5MTlhMmRmMDQ0OTczNjciLCJiYWFzX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjZkIiwiYmFhc19pZGVudGl0eSI6eyJpZCI6IjYwOTkyYjI2NGNlZjk5MTI3NmFjZThkYyIsInByb3ZpZGVyX3R5cGUiOiJsb2NhbC11c2VycGFzcyIsInByb3ZpZGVyX2lkIjoiNWZkOWVkZTgxOTE5YTJkZjA0NDk3NTIzIn0sImV4cCI6MTYzMzQ1OTE5MywiaWF0IjoxNjI4Mjc1MTkzLCJzdGl0Y2hfZGF0YSI6bnVsbCwic3RpdGNoX2RldklkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjYzIiwic3RpdGNoX2RvbWFpbklkIjoiNWZkOWVkZTYxOTE5YTJkZjA0NDk3MzY3Iiwic3RpdGNoX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjZkIiwic3RpdGNoX2lkZW50Ijp7ImlkIjoiNjA5OTJiMjY0Y2VmOTkxMjc2YWNlOGRjIiwicHJvdmlkZXJfdHlwZSI6ImxvY2FsLXVzZXJwYXNzIiwicHJvdmlkZXJfaWQiOiI1ZmQ5ZWRlODE5MTlhMmRmMDQ0OTc1MjMifSwic3ViIjoiNjA5OTJiMjc3MTY4NjBhYWRiMjJjZDI3IiwidHlwIjoicmVmcmVzaCJ9.IeR5lNvMPFvT_1vDIrW5zXs_mAccOhEKthn71W4Udrc
Content-Type: application/json;charset=utf-8
I'm looking into why this could happen right now.
The refresh should happen after 30 minutes btw.
Great , for now can you handle it on server side by creating a static token or it is good if you can able you fixed it easily
We are losing data because of this issue which is added by offline.
On Sat, Aug 7, 2021, 12:57 AM Christian Melchior @.***> wrote:
I can reproduce this now. It is indeed refreshing the access token that fails with 400 Bad Request.... an example request is here:
POST https://realm.mongodb.com/api/client/v2.0/auth/session Accept: application/json Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYWFzX2RhdGEiOm51bGwsImJhYXNfZGV2aWNlX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjYzIiwiYmFhc19kb21haW5faWQiOiI1ZmQ5ZWRlNjE5MTlhMmRmMDQ0OTczNjciLCJiYWFzX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjZkIiwiYmFhc19pZGVudGl0eSI6eyJpZCI6IjYwOTkyYjI2NGNlZjk5MTI3NmFjZThkYyIsInByb3ZpZGVyX3R5cGUiOiJsb2NhbC11c2VycGFzcyIsInByb3ZpZGVyX2lkIjoiNWZkOWVkZTgxOTE5YTJkZjA0NDk3NTIzIn0sImV4cCI6MTYzMzQ1OTE5MywiaWF0IjoxNjI4Mjc1MTkzLCJzdGl0Y2hfZGF0YSI6bnVsbCwic3RpdGNoX2RldklkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjYzIiwic3RpdGNoX2RvbWFpbklkIjoiNWZkOWVkZTYxOTE5YTJkZjA0NDk3MzY3Iiwic3RpdGNoX2lkIjoiNjEwZDgxZjkyOTE2NDU5M2FhNTBlNjZkIiwic3RpdGNoX2lkZW50Ijp7ImlkIjoiNjA5OTJiMjY0Y2VmOTkxMjc2YWNlOGRjIiwicHJvdmlkZXJfdHlwZSI6ImxvY2FsLXVzZXJwYXNzIiwicHJvdmlkZXJfaWQiOiI1ZmQ5ZWRlODE5MTlhMmRmMDQ0OTc1MjMifSwic3ViIjoiNjA5OTJiMjc3MTY4NjBhYWRiMjJjZDI3IiwidHlwIjoicmVmcmVzaCJ9.IeR5lNvMPFvT_1vDIrW5zXs_mAccOhEKthn71W4Udrc Content-Type: application/json;charset=utf-8
I'm looking into why this could happen right now.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/7501#issuecomment-894473331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7ZYDRX5HH7ALTJAUWRIADT3QZT5ANCNFSM46ZIE6OQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
@kunalgharate You shouldn't loose data due to this. Any data written to the local database is not lost, but it isn't synced until you log out and back again. I think I have located the bug and am trying to verify it now.
If its stucked on login screen i need to clear the to restart the app . This time forcefully i have to delete data from the local db
On Mon, Aug 9, 2021, 1:03 PM Christian Melchior @.***> wrote:
@kunalgharate https://github.com/kunalgharate You shouldn't loose data due to this. Any data written to the local database is not lost, but it isn't synced until you log out and back again. I think I have located the bug and am trying to verify it now.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realm/realm-java/issues/7501#issuecomment-895012768, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7ZYDSJTYOXOQGUMMRGVO3T36AF3ANCNFSM46ZIE6OQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
As @kunalgharate said, the app needs to be cleared to get it to work again, so data is lost.
Besides, if I read the docs correctly, even logging out would result in data loss:
You can log out any user, regardless of the authentication provider used to log in, using the user.logOut() or user.logOutAsync() methods. Both methods:
delete locally stored user credentials from the device immediately halt any synchronization to and from the user's realms mark the user's realms for deletion the next time the app restarts
Because logging out halts synchronization, you should only log out after all local Realm updates have uploaded to the server.
@Trailqueen @kunalgharate Sorry for the confusion. I just double-checked our implementation and User.logOut()
does not delete the Realm. The Javadoc is wrong. It is a product of us having a few iterations on this part of the API. There is also a package-private remove()
method that does logout and remove the Realm. I'll be working on exposing that again and making the Javadoc correct.
I have located the root cause. It is an internal refresh of the access token that happens on the thread that created the App
instance, which in most cases is the main thread. But trying to run network code there results in an android.os.NetworkOnMainThreadException
, which is then swallowed by our internal implementation.
I'm working on a fix right now. A temporary work-around should be to create the App
instance on a background thread. Since that instance is otherwise thread-safe, this should work fine, except it is slightly more complicated to instantiate.
@cmelchior have you fixed that issue ?
@cmelchior Thank you for acknowledgment but the request is still in progress could you please try to merged it asap
@cmelchior - Any estimate on when this will be available in the SDK?
@cmelchior when will 10.8.0 be uploaded on maven?
10.8.0 has been released and should be available on Maven Central now. Note it will probably take a few hours to show up in their search results, but it should be usable from Gradle.
Realm version 10.5.1
https://developer.mongodb.com/community/forums/uploads/default/optimized/3X/7/b/7bb3ba563ea169e0d6b52a2a0dcba439742571f4_2_690x310.png
https://github.com/WildAid/o-fish-android/blob/main/app/src/main/java/org/wildaid/ofish/data/RealmDataSource.kt
fun restoreLoggedUser(): io.realm.mongodb.User? { return realmApp.currentUser()?.also { instantiateRealm(it) } }
while restoring its not working