I can't read a collection at first time using Realm

Hello everyone.

I have an app with a Realm integration. I found that, when I create the App Service and set security rules with read-only permission, I’m not able to read the data from my collection. But, if I set permissions to write and read, get the data (reading successfully) and then set read-only permissions again, I can read the data properly.

My question is, why the first time was not working? I already checked that client code is correct. Has anyone faced this situation before?

Hi, are you using Partition Sync or Flexible Sync? And are you waiting a bit of time between enabling sync trying to download to the Realm?

The reason I ask is that it does take a bit of time to initial sync the data into Atlas Device Sync and it is possible you are connecting before that happens and then when you switch to read/write it is just a timing issue in that the initial sync has completed.

If that is not the case, if you could send a link to your application in services.cloud.mongodb.com I can take a look at the logging. If you can send a link directly to the log in the UI for your test, that would be extra helpful.


Hi. I’m using Flexible Sync. And the flow is the following:

  • Fist, I set the project: create the App Service, set Custom JWT Authentication, set Rules, and other configuration stuff. Finally, I create some random data to read.

  • Then, I create the client app and try to read the data. JWT Authentication is working fine, but read the data first time was impossible at the moment. Just after enable read-write permissiones, and then re-set read-only, I was able to read them.

When you say about send a link to my application, do you mean a repo link, such a Github link or something like that?

Hi Tyler. This link is useful for you?


Got it. That link is helpful. I do suspect something about your testing methodology is a bit off given that this is a path many users take (I myself just tried to reproduce this and it is working just fine for me). Do you mind getting your application into the state that no data is being synced (do not do the update to read/write and then update to read-only) and then let me know and I can take a look at your application?

Understood. Let me create another project to replicate the issue from the beginning.

This is a link using an app service as you requested:


Thank you for providing this. Unfortunately I wasn’t able to get to this today, but we will try to take a look early next week and follow up.


Understood. We’ll see next week.

Hi Tyler. Do you have some news?

Hello, I apologize for the delay in response here. I am responding for Tyler. Are you still encountering this issue? If so, are you able to share a snippet of your code? It would be helpful in debugging the issue.

One thing I am able to see on my end is that the data from your Atlas Cluster finished synchronizing to your App Services Application at 2/23/24 12:32:10.711 PM ET but I do see some sync connections before that time. These connections would not have been able to read any data until the initial synchronization of data from your Atlas Cluster completed.

Hi Rushil. I tried with a new permissions configuration, and issue was gone. Thanks for following.

1 Like

You’re welcome! Feel free to reach out if you encounter any other issues.

1 Like