0

I have set up my firebase emulator up an running enter image description here

On my main programm, at the start of my flutter web app I have the following code:

void main() async {

  WidgetsFlutterBinding.ensureInitialized();
   await Firebase.initializeApp();

  FirebaseFirestore.instance.settings = Settings(
    host: '127.0.0.1:8080',
    sslEnabled: false,
  );

Yet when I try to get the document I get the following error:

Failed to get Document because the client is offline

My firebase.json is the following:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "emulators": {
    "firestore": {
      "port": 8080
    },
    "hosting": {
      "port": 5000
    },
    "ui": {
      "enabled": true
    }
  }
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
user14624595
  • 874
  • 7
  • 19
  • try `localhost:8080` rather than `127.0.0.1:8080` – Methkal Khalawi Jan 13 '21 at 15:43
  • it is not working with localhost:8080 – user14624595 Jan 13 '21 at 15:54
  • this has already been answered here [Flutter + firebase: Configure app to use local firebase emulator](https://stackoverflow.com/questions/58693838/flutter-firebase-configure-app-to-use-local-firebase-emulator) – Methkal Khalawi Jan 14 '21 at 09:14
  • I did try to follow this prior to me posting this issue. I still get the error: `Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds`. Programm then proceeds to `[WatchStream]: (3d19be0) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.` . And then queries the online FireStore. – user14624595 Jan 15 '21 at 10:48
  • Does this answer your question? [@firebase/firestore: Firestore (5.0.4): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds](https://stackoverflow.com/questions/50674482/firebase-firestore-firestore-5-0-4-could-not-reach-cloud-firestore-backend) – Dharman May 12 '21 at 14:23
  • Carlos's answer is correct – user14624595 May 13 '21 at 15:24

1 Answers1

2

Turns out everything was set up correctly. The reason I could not communicate with the Firebase Emulator was my Karspersky antivirus. If anyone else has the same issue try to disable your additional antivirus.

user14624595
  • 874
  • 7
  • 19