Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Firestore emulator on physical IOS / Android device

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'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})
like image 628
eyerishluv Avatar asked Dec 31 '22 16:12

eyerishluv


1 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')
like image 129
Gwater17 Avatar answered Jan 05 '23 15:01

Gwater17