firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 925 forks source link

Emulator on real iOS device: An internal error has occurred #4154

Open MorelSerge opened 2 years ago

MorelSerge commented 2 years ago

[REQUIRED] Environment info

firebase-tools: 10.1.5

Platform: MacOS Monterey 12.1 M1, iPhone 8 iOS 15.1

[REQUIRED] Test case

See below

[REQUIRED] Steps to reproduce

  1. Run the emulators
  2. Add your local computer's IP as host (also tried 0.0.0.0)
  3. For example
    "emulators": {
        "auth": {
          "port": 9099,
          "host": "192.168.20.90"
        },
        "functions": {
          "port": 5001,
          "host": "192.168.20.90"
        },
        "firestore": {
          "port": 8080,
          "host": "192.168.20.90"
        },
        "hosting": {
          "port": 5000,
          "host": "192.168.20.90"
        },
        "ui": {
          "enabled": true,
          "port": 4000,
          "host": "192.168.20.90"
        },
        "pubsub": {
          "port": "8085",
          "host": "192.168.20.90"
        }
      }
  4. Run the emulators
  5. Open a Flutter app
  6. Connect to the emulators, e.g.
    String host = '192.168.20.90';
    FirebaseFirestore.instance.useFirestoreEmulator(host, 8080);
    FirebaseStorage.instance.useStorageEmulator(host, 9199);
    FirebaseAuth.instance.useAuthEmulator(host, 9099);
  7. Observe that no data is returned and the connection fails
  8. If you disallow local network connection on your iPhone, the error changes to "you seem to be offline"
  9. I can browse to the emulator UI on my real device, so the IP is definitely correct

[REQUIRED] Expected behavior

My real iOS device to find my local emulator on my laptop

[REQUIRED] Actual behavior

Flutter Firebase throwing errors

GTMSessionFetcher invoking fetch callbacks, data {length = 215, bytes = 0x7b0a2020 22657272 6f72223a 207b0a20 ... 205d0a20 207d0a7d }, error Error Domain=com.google.HTTPStatus Code=400 "(null)" UserInfo={data={length = 215, bytes = 0x7b0a2020 22657272 6f72223a 207b0a20 ... 205d0a20 207d0a7d }, data_content_type=application/json; charset=utf-8}
8.10.0 - [Firebase/Firestore][I-FST000001] WatchStream (1037b0d68) Stream error: 'Unknown: An internal error has occurred, print and inspect the error details for more information.'
google-oss-bot commented 2 years ago

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

jpangburn commented 2 years ago

This might be a regression. I have a similar setup and this used to work- my physical device is showing old data from when it was able to connect to Firestore emulator. But now I see this same error over and over in the logs that @Vluf reports. I haven't used the physical device in a week or so. I tried another physical device, same results.

I've also verified from Safari on my mobile device that I can go http://:5002 and get the Firebase Hosting setup complete screen, so doesn't look like a firewall issue.

Simulated devices are connecting fine.

jpangburn commented 2 years ago

I had the following line to turn off persistence:

firestore.settings = const Settings(persistenceEnabled: false);

This was there because it says to turn off persistence with the emulator (although I admit I don't really understand why) https://firebase.google.com/docs/emulator-suite/connect_firestore. When I removed this then the real device started connecting to Firestore again.

maks commented 11 months ago

I am seeing this same behaviour when trying to use a Flutter app using the Firebase SDK to use a local Firebase emulator for authentication. The error message I see it:

FirebaseAuthException ([firebase_auth/internal-error] An internal error has occurred, print and inspect the error details for more information.)

I can confirm its some sort of iOS device specific issue because the exact same app running on an Android device on the very same local wifi network can connect just fine. Likewise the iOS simulator can also connect to the Firebase Emulator without any issues. I also do not think its an issue with permissions as when I first run the app on the iphone, I get the dialog prompt to allow the app to "access services on the local network" which I do allow. If I don't allow via the local network access dialog I get a different error:

FirebaseAuthException ([firebase_auth/network-request-failed] Network error (such as timeout, interrupted connection or unreachable host) has occurred.)

so I don't again I don't think that's the cause of the issue here and I'm at a loss as to why this is not working.

EDIT: Sorry I submitted this without including version details: using Flutter 3.13.5, firebase_core: ^2.15.1, firebase_auth: ^4.7.2, Firebase emulator: 12.5.4 (running on Linux or MacOS host) with the app running on a iphoneSE 2022 iOS 16.6

suesitran commented 11 months ago

follow up, I'm seeing this issue in my app too. It's happening in Firestore for me, iOS device (physical device), and Firestore server. I do not use any emulator.

[FirebaseFirestore][I-FST000001] WriteStream (13dd32ad8) Stream error: 'Unknown: An internal error has occurred, print and inspect the error details for more information.'
chad-bekmezian-snap commented 6 months ago

Any updates or solutions on this issue? I am also experiencing it