MongoDB Realm all users automatically loggingout after deployment

I am using MongoDB Realm for authentication in my Rest API writen in node js.

When I do the deployment that Realm authorization token getting expired for all the users. My assumption is MongoDb Realm is creating temp files inside the application directory and using that for authorization. Users are getting logged out because of this files are getting deleted during the deployment.

If anyone has some idea please help me out

Are this temporary files needed?

Hi @VISHNU_KUMAR ,

Yes, that’s correct: the files inside the mongodb-realm/<app-id>/server-utility/metadata folder keep some information about the users that have logged in. It’s also possible to open the .realm file with Realm Studio, and check the identities. If, as part of your deployment, you delete that folder, that information is gone, and a new login is needed (even though you never did an explicit logout).

1 Like

Hi @Paolo_Manna
I will explain the deployment process we follow. Each time we make changes in the source code, During the deployment, we create a new docker image. This new image gets deployed in AWS EC2. Even if we are doing the source code change in a single file. The new docker image will replace the old docker image. (We are following this method from the beginning of this project) So my assumption is the temporary files associated with old docker images get lost during the deployment process. So all the users are getting logout. Is there method to get old realm tempfile?

Hi @VISHNU_KUMAR ,

So, if I understand it correctly, you create what amounts to Realm’s idea of a “new” device, but using an already existing DB? If that’s the case, it can’t work: Device Sync assumes that each remote device has a different unique id, in order to track which changes have been applied, and which haven’t. Keeping the same local data file, while essentially changing the whole environment around it, basically means that Realm can only discard it, and get it again from scratch.

I may have misunderstood (installing a client in Docker isn’t a usual setup), feel free to clarify the details and the rationale behind them.

1 Like