I’m getting the following error in my Flutter app when trying to run it on an Android Emulator.
Exception has occurred.
AppException (AppException: non-zero custom status code considered fatal, link to server logs: null)
The source of the error seems to be an OS Error:
Failed host lookup: 'realm.mongodb.com'
OSError (OS Error: No address associated with hostname, errno = 7)
"No address associated with hostname"
The code being called triggering the issue is the registration functionality, which is mostly just from the documentation.
final jwtCredentials = Credentials.jwt(token);
currentUser = await app.logIn(jwtCredentials); // Problematic
I’ve been trying to figure out why I suddenly started receiving this error but I am out of ideas. For a second if I skipped the errors, it would still continue and let me use my app as expected. But now I’m unable to do that either.
I haven’t changed any permissions, and I have the Internet permission added already. I do have a working internet connection and the browser on the emulator works as well. I tried restarting the emulator and my computer but that didn’t work either.
I tried with realm version 1.3.0 and 1.4.0 but I’m getting the same issue. I’m not sure what the issue is since as far as I know, I didn’t change anything. I even tried reverting anything I might have changed, but this error is still persisting. My cluster and app services are on GCP.
I wasn’t manually looking up realm.mongodb.com in the emulator, it’s just from Realm functionality. Also, it was working just fine for months. I didn’t disable the internet on the emulator either. Browsing through Chrome is working normally on the emulator still. Also, requests to Firebase Auth are going through normally still.
Pinging all of the addresses doesn’t fail with an unknown host error, but it seems I’m getting 100% packet loss with 0 packets received. I’m not sure why this could be the case.
I’ve tried pretty much all of the suggested solutions in the SO thread but still facing the same issue.
The pings on my development machine are run successfully. In the emulator using adb shell is where I’m getting the 100% packet loss.
Also, I just realized, is there a reason there is no GCP alias being shown with nslookup? If I try to visit the global gcp alias in a browser it seems to load as intended. My cluster and Atlas app are both on GCP. In case that is relevant to the situation.
On my end, when running ping under adb, it works fine (just to proof that ICMP does indeed work with realm.mongodb.com):
❯ adb -s emulator-5554 shell
emu64a:/ $ ping realm.mongodb.com
PING eu-central-1.lb-b.r53.aws.cloud.mongodb.com (35.157.33.91) 56(84) bytes of data.
64 bytes from ec2-35-157-33-91.eu-central-1.compute.amazonaws.com (35.157.33.91): icmp_seq=1 ttl=255 time=40.1 ms
64 bytes from ec2-35-157-33-91.eu-central-1.compute.amazonaws.com (35.157.33.91): icmp_seq=2 ttl=255 time=31.1 ms
64 bytes from ec2-35-157-33-91.eu-central-1.compute.amazonaws.com (35.157.33.91): icmp_seq=3 ttl=255 time=34.5 ms
We need to get your network in shape, so that the emulator can do DNS lookups. The realm SDK needs to do a DNS lookup of realm.mongodb.com, and it need to be able to connect with https on port 443.
When you say you get 100% packet loss on adb, is that for both realm.mongodb.com, google.com, and 8.8.8.8?
Also, what emulator image (API level) are you using? I’m using 33.