Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable connect to Firestore Emulator from another physical device (able to connect to auth, functions, storage services) #5872

Open
just7mile opened this issue May 22, 2023 · 7 comments

Comments

@just7mile
Copy link

[REQUIRED] Environment info

firebase-tools: 12.1.0

Platform: MacOS

[REQUIRED] Test case

The Firebase Emulator Suite is started on the Mac with host as 0.0.0.0 for all services. An iPhone device is connected to the Mac via USB cable and internet sharing is enabled. Ports of services are UI: 10100, Functions: 10200, Auth: 10300, Firestore: 10400.

I'm able to open the Emulator UI in a Safari/Firefox browser by accessing http://macbook-pro.local:10100 or http://<mac-ip-address>:10100, it opens the Auth emulator when clicking on Go to auth emulator button and shows list of users. Same with functions and storage emulators. BUT, it gives timeout with firestore emulator, and never loads it.

It is a problem, because I'm not being able to test my app. I'm connecting to the Emulator Suite from my app which is running on a physical iPhone device connected to the Mac via USB, and I'm able to log into the app, but I'm not able to get documents from the firestore. On hot restart the user is authenticated, which means the Firebase Auth is able to connect to the emulator, but the Firestore keeps giving [cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff and [FirebaseFirestore][I-FST000001] WatchStream (10521fe78) Stream error: 'Unavailable: failed to connect to all addresses' errors.

The app is developed in Flutter, and here is my setup:

FirebaseFirestore.instance.settings = Settings(
      host: 'macbook-pro.local:10400',
      sslEnabled: false,
      persistenceEnabled: false,
);

 FirebaseFirestore.instance.useFirestoreEmulator('macbook-pro.local', 10400);

[REQUIRED] Steps to reproduce

  1. Setup a Firebase Emulator Suite.
  2. Connect to the host via another device.
  3. Open Emulator UI in a browser.
  4. Click on the Go to firestore emulator button.

[REQUIRED] Expected behavior

It opens the page with a loading indicator in the collection column saying Loading collections, and after few moments it timeouts.

[REQUIRED] Actual behavior

Should be able to load, similar to Auth, Functions or Storage services.

@christhompsongoogle
Copy link
Contributor

Question, does localhost work in place of macbook-pro.local ? Are you using Node 18+ and/or is the machine resolving to IPv6 addresses?

@just7mile
Copy link
Author

Question, does localhost work in place of macbook-pro.local ? Are you using Node 18+ and/or is the machine resolving to IPv6 addresses?

Thank you for your response. No, localhost does not work at all (the UI - http://localhost:10100 does not open). Yes, the Node version is v18.16.0. What do you mean by is the machine resolving to IPv6 addresses? How can I find out this?

@aalej
Copy link
Contributor

aalej commented May 26, 2023

Hi @just7mile, just to verify, when you mentioned “I'm able to open the Emulator UI in a Safari/Firefox browser”, do you mean you’re able to access the Emulator UI on your Mac machine or your iPhone, or both?

If it’s both, could you let us know if you’re able to access the Firestore Emulator UI on your Mac and if it only does not load when accessing via your iPhone?

I’m trying to reproduce this issue, but currently I’m only using an iOS emulated device to run the Flutter app on. I’m able to write to Firestore Emulator without any issues. Could you try using an iOS emulated device on your Mac to see if a different behavior would be shown?

@just7mile
Copy link
Author

Hello @aalej, I am able to access the Emulator UI from both the iPhone physical device and the Mac machine.

I am able to access Firestore Emulator UI on the Mac. Also, accessing Firestore emulator from the Flutter app works as expected when running the app on an iOS emulated device.

I wanted to test the app on a physical iPhone devices, so I connected an iPhone to the Mac machine via USB cable (type-C to lighting directly, without any adapters). The Firebase Emulator is running on the Mac machine. I am able to open the Emulator UI in the iPhone's Safari and Firefox browsers (by accessing http://macbook-pro.local:10100). And I'm able to go to the Auth, Storage, and Functions Emulator UI pages (just by clicking on the corresponding Go to <service> emulator button), and their data is displayed on their pages as expected (list of users, storage folders, function logs). But, when going to the Firestore Emulator UI page, it is opened with a circular loading indicator in the collections (first) column, which goes for some time, then the page becomes blank white (it gives timeout).

Also, when running the Flutter app on the physical iPhone device, I am able to sign in via Firebase Auth, and after hot reloads/restarts the user stays authenticated, so the Firebase Auth works as expected. But, I am not able to get documents from the Firestore. It throws errors as mentioned in this issue.

I thought there is some problem specifically with the Firestore and created this issue, as other services are working as expected.

@just7mile just7mile changed the title Unable connect to Firestore Emulator from another device (able to connect to auth, functions, storage services) Unable connect to Firestore Emulator from another physical device (able to connect to auth, functions, storage services) May 26, 2023
@christhompsongoogle
Copy link
Contributor

The Emulator UI is running on the mac, so I would expect the iPhone should be able to load the firestore page if the auth/storage pages work. Maybe something is incorrect about the JWT/auth forwarding?

@christhompsongoogle christhompsongoogle self-assigned this May 30, 2023
@maks
Copy link

maks commented Sep 21, 2023

@christhompsongoogle I am seeing exactly the same thing here. I commented on another issue: #4154 (comment)
before finding that this seems to be a newer report of the same problem.

As per my comment on the other issue I am able to connect to the Firebase emulator instance on the same wifi network with the same Flutter app build on a physical Android device with no issues, it just doesn't work on iOS despite my verifying that my app does have the "Local Network" permission (I double check this in the iOS Settings screen for my app). I can likewise access the Emulator UI webpages in Safari on my iphone so it definitely can at least open HTTP connections to the laptop where I have the Firebase Emulator running.

@cpAdm
Copy link

cpAdm commented Feb 26, 2024

Got same issue on Windows 10 + Android device. Temporarily disabling Windows firewall fixed the issue, so it's a firewall issue.

edit:
Specific, allowing the Java application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants