Firebase Firestore emulator on physical IOS / Android device

Viewed 2010

Okay, I'm done with all this research.

I'm trying to get the Firebase - Firestore database emulator to work on my physical IOS device via the Expo application while I develop.

I can get Localhost to work in a browser and 10.0.2.2:(8080) to work via Android emulator. However, I cannot get my PHYSICAL IOS device, to work. I get firebase couldn't connect within 10 seconds error.

Tried localhost, tried the ip provided in the expo app 192.168.x.x tried the ip address given in my current wifi location, nothing.

I've already done EXTENSIVE research into different configuration. I'm looking for someone who has managed to get it to work and know their steps. Am I missing a config setting, etc, etc.

Being that it works in web, emulator I don't believe I have.

I'm using this piece of code to connect Android Emulator / Web browswer

firebase.firestore().settings({ experimentalForceLongPolling: true, host:'10.0.2.2:8084'
,ssl:false})

Please, no guessing in the replies only looking for those who have reproduced the solution to the exact question in hand.

Thanks

2 Answers

In your firebase.json set a host parameter of "0.0.0.0" for every emulator you're using.

Code I use to connect to the emulator w/ a real iOS device is below

firebase.json

{
  "emulators": {
    "auth": {
      "port": 9099,
      "host": "0.0.0.0"
    },
    "functions": {
      "port": 5001,
      "host": "0.0.0.0"
    },
    "firestore": {
      "port": 8080,
      "host": "0.0.0.0"
    },
    "database": {
      "port": 9000,
      "host": "0.0.0.0"
    },
    "ui": {
      "enabled": true
    }
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "database": {
    "rules": "database.rules.json"
  }
}

Then on the client add

realtimeDatabase.useEmulator(yourLocalIp, 9000);
firestore.useEmulator(yourLocalIp, 8080);
firebase.functions().useEmulator(yourLocalIp, 5001);     
auth.useEmulator('http://yourLocalIp:9099')

Final answer. Update your packages. (I'm pissed at myself)

I spent countless hours trying to figure out a problem that didn't have a solution yet cause it came out in future versions.

So I had Firebase javascript sdk 7.9 after updating to sdk 8.29 it worked perfect on a physical IOS device. I didn't use useEmulator, I use this piece of code.

if(firebase.apps.length === 0){
       
    firebase.initializeApp(config)      
        
    firebase.firestore().settings({ 
         experimentalForceLongPolling: true,
         host:'192.168.X.XX:8089'         
         ,ssl:false
         })        

    } else {      
        firebase.app()
    }

export default firebase

settings method worked great for me, not sure if i'll find other issues not using the useEmulator or if that is for different types of platforms. I'm using expo/React Native.

Thanks for responses.

Related