realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Problem with getting Realm instance with Android SDK: Infinite session POST request #7603

Closed zhandosm closed 2 years ago

zhandosm commented 2 years ago

How frequently does the bug occur?

All the time

Description

When I try to initiate Realm instance on an android device (Kotlin), on the user authentication stage the app gets stuck in an infinite loop trying to request a session.

I haven't found any workarounds or solutions yet.

Note: Due to NDA concerns, I can't post the source code, but I've listed detailed steps to re-create the problem

Stacktrace & log output

2021-11-26 05:09:12.781 25241-27531/com.hansjin.drdiary_android D/REALM_JAVA: HTTP Request =
POST https://ap-southeast-1.aws.realm.mongodb.com/api/client/v2.0/auth/session
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiYWFzX2RhdGEiOm51bGwsImJhYXNfZGV2aWNlX2lkIjoiNjE5ZjJkOTlhNmM4OWZkNjE4MzAxOWE3IiwiYmFhc19kb21haW5faWQiOiI2MTgwZjg1NzgxOWRmNTNkMDY5YmY2YTMiLCJiYWFzX2lkIjoiNjE5ZjJkOTlhNmM4OWZkNjE4MzAxOWE4IiwiYmFhc19pZGVudGl0eSI6eyJpZCI6IjYxODBmYWRlODE5ZGY1M2QwNjlkNzg2MyIsInByb3ZpZGVyX3R5cGUiOiJhcGkta2V5IiwicHJvdmlkZXJfaWQiOiI2MTgwZjg1NzgxOWRmNTNkMDY5YmY2YTAifSwiZXhwIjoxNjQzMDA1ODQ5LCJpYXQiOjE2Mzc4MjE4NDksInN0aXRjaF9kYXRhIjpudWxsLCJzdGl0Y2hfZGV2SWQiOiI2MTlmMmQ5OWE2Yzg5ZmQ2MTgzMDE5YTciLCJzdGl0Y2hfZG9tYWluSWQiOiI2MTgwZjg1NzgxOWRmNTNkMDY5YmY2YTMiLCJzdGl0Y2hfaWQiOiI2MTlmMmQ5OWE2Yzg5ZmQ2MTgzMDE5YTgiLCJzdGl0Y2hfaWRlbnQiOnsiaWQiOiI2MTgwZmFkZTgxOWRmNTNkMDY5ZDc4NjMiLCJwcm92aWRlcl90eXBlIjoiYXBpLWtleSIsInByb3ZpZGVyX2lkIjoiNjE4MGY4NTc4MTlkZjUzZDA2OWJmNmEwIn0sInN1YiI6IjYxODBmYWRkODE5ZGY1M2QwNjlkNzdiOCIsInR5cCI6InJlZnJlc2gifQ.yDkFXDkIKNVfodBNduiHaFTkV94brAuPVmr7DXeBxYk
Content-Type: application/json;charset=utf-8

Can you reproduce the bug?

Yes, sometimes

Reproduction Steps

Steps

  1. Backend setup

    • Setup Realm App, data models, permissions etc.
    • User authentication provider: API Keys
  2. App (Client-Side)

    • Define Data Models
    • Initialize Realm App
    • Configure Realm App (App_id, Sync etc.)
    • Authenticate user
    • THE BUG: No throwing error -> Infinite Request for Session

Version

10.8.1

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android 11 (30)

Build environment

Android Studio version: Android Studio Arctic Fox | 2020.3.1 Patch 1 Android Build Tools version: 30.0.2 Gradle version: 4.2.2

clementetb commented 2 years ago

Thanks for reporting this bug. We are trying to reproduce the issue, is there any special situation about the login? Is it the firs t logging to the app? Has any logged out any user from the app? Was the app on the background while logging in?

zhandosm commented 2 years ago

Thanks for reporting this bug. We are trying to reproduce the issue, is there any special situation about the login?

Is it the firs t logging to the app?

Has any logged out any user from the app?

Was the app on the background while logging in?

With the same set of settings, the issue stopped appearing in the next days. Ever since then we were unable to re-create the case, unfortunately.

Possibly, a simultaneous login from two devices with the same partition key and the way sessions were handled could be the reason.

We've tried it, but the issue didn't appear anymore.

bmunkholm commented 2 years ago

thanks @zhandosm. We will close this for now, but not hesitate to create a new issue in case you see this again. Thanks!