Problem with asyncOpen

I am experiencing a problem with Realm.asyncOpen this morning. I usually call this function at startup

Realm.asyncOpen(configuration: user.configuration(partitionValue: “user_id=(uid)”),

on my iOS program. About half the time this function just never comes back. I used work fine up until this morning. I tried this on a new app and new cluster - same problem.

Richard Krueger

Can you share server or client Logs please?

Ian,

My Realm Id is cosyncstoragetest-agmju

The login works fine and I get this log

OK

Feb 05 13:45:38-05:00

57ms

AuthenticationArrow Right Iconlogin

local-userpass

60141f2266abe05ca0f416c5

601d92529daad1506b74f461

The function to open the Realms is this

func initRealms(onCompletion completion: @escaping (Error?) -> Void) {
    if  let user = self.app.currentUser,
        let uid = self.currentUserId {
        
        // open user realm
        Realm.asyncOpen(configuration: user.configuration(partitionValue: "user_id=\(uid)")) { result in
            
            switch result {
            case .success(let realm):
                self.userRealm = realm
                
                Realm.asyncOpen(configuration: user.configuration(partitionValue: "public")) { result in
                    
                    switch result {
                    case .success(let realm):
                        self.publicRealm = realm
                        completion(nil)

                    case .failure(let error):
                        fatalError("Failed to open public realm: \(error)")
                    }
                    
                }

            case .failure(let error):
                fatalError("Failed to open user realm: \(error)")
            }
            
        }
    }
}

The output logs from Xcode is this

2021-02-05 13:45:38.003134-0500 CosyncStorageSample[8391:315745] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed

2021-02-05 13:45:40.709796-0500 CosyncStorageSample[8391:315899] Sync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, async open = false, client reset = false
2021-02-05 13:45:40.754705-0500 CosyncStorageSample[8391:315899] Sync: Connection[1]: Connected to endpoint ‘3.210.32.164:443’ (from ‘192.168.86.22:63744’)
2021-02-05 13:47:52.670704-0500 CosyncStorageSample[8391:315899] Sync: Connection[1]: Connection closed due to error
2021-02-05 13:47:52.751124-0500 CosyncStorageSample[8391:315899] Sync: Connection[1]: Connected to endpoint ‘3.210.32.164:443’ (from ‘192.168.86.22:63835’)

Up until this morning, this code worked absolutely fine. It now hangs on the first asyncOpen() and never comes back intermittently, but about 80% of the time.

I have bundled Swift Package Dependencies Realm 10.5.1 and RealmDataBase 10.3.3

I have also tried this on a brand new cluster and application - same problem.

Richard Krueger

Not a critique or even related to the issue but this section of code can fail silently and you’ll never know about it or why.

if  let user = self.app.currentUser,
        let uid = self.currentUserId {

We were using similar code and spent a day trying to figure out why our app would never log in ‘out of the blue’ and it was a uid issue.

1 Like

Yes it could fail if you can’t unwrap user, but right now it’s failing on the asyncOpen() - it just does not come back. This only started happening this week, and it’s intermittent to boot.

My issue with asyncOpen() has magically stopped happening - maybe the server gods have decided to smile on me again. It might have something to do with the fact that it is 2AM here on East Coast - in the pandemic time is but a mere illusion. Speaking of your topic Jay, what was your issue with?

if  let user = self.app.currentUser,
        let uid = self.currentUserId {

Now you have peaked my curiosity. In my code, I define currentUserId as

    var currentUserId: String? {
        if  let user = self.app.currentUser {
            let uid = user.id
            return uid
        }
        return nil
    }

Richard

@Richard_Krueger

The issue we had was due to another coding error, which was caused by the app crashing somewhere ‘in the middle’ and currentUser was still populated but was not authenticated.

It would fail silently and we had to figure out why - just adding some else statements with error handling took care of that - no biggie.

The comment was more for troubleshooting than anything.

1 Like

I’m having the same issue. Without any modifications on the client or the server, Realm.GetInstanceAsync (C#) is hanging (it actually returns after 5 minutes or so if I remove the timeout).

This happened last Friday, yesterday and now today.

I spoke too soon, it happening to me again tonight at 7PM EST. I will wait 5 minutes to see if it comes back. I am going to build a super simple Realm app, where this happens, and post it to the forum for further examination.

Richard

@Richard_Krueger

It was the same for me, yesterday I couldn’t connect, then for some hours it was normal again, then today about 2PM UTC the issue reappeared.

I already opened a support ticket about this issue but there’s no information about it for now.

So I have essentially condensed this down a 10 line Realm Swift program on a fresh MongoDB Realm app and Atlas cluster. It hangs every time on asyncOpen. I published a public GitHub repo for anyone to try this out.

Currently this is built against a MongoDB app with a Realm Id of

REALM_APP_ID = "hangingapp-lxnaw"

There is one user called john@doe.com with a password “mongodb”. The app is configured with a simple Email/Password authentication.

This definitely seems like a server problem from the latest deploy.

Richard Krueger

I tested the project a few times now and I see the same issue. Sometimes it actually works as it should returning in 4 or 5 seconds, but most of the time it takes more than 3 minutes.

@Luccas_Clezar there is definitely something going on that’s new. This was not happening until Friday consistently - then again I wasn’t programming Wednesday or Thursday - doing documentation work instead. The example that I published is as basic as it gets.

It is 19:49 EST - the problem seems to be fixed. I will try again in the morning.

Richard