Firestore emulator not supporting HTTP2 / gRPC
See original GitHub issueEnvironment info
firebase-tools: 8.6.0
Platform: macOS Catalina 10.15.6
Test case
import firestore from '@react-native-firebase/firestore';
firestore().settings({host: 'abc123.ngrok.io', ssl: true});
...
componentDidMount = async () => {
firestore().collection('users').add({name: 'Sam'});
}
Steps to reproduce
Run firebase emulators:start
.
Run ngrok.
authtoken: xxxx
tunnels:
firestore:
addr: 8080
proto: http
bind-tls: true
Run the app with ngrok host.
Expected behavior
A user is created in the local Firestore instance.
Actual behavior
No user is created. After some investigation, it seems that the emulator is not using HTTP/2 and therefore not able to support the gRPC protocol required for Firestore. The emulator is running, I can modify the Firestore data through the local UI web interface, and if I hit the ngrok link from a browser I get the βOkβ response.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Developers - Firestore emulator not supporting HTTP2 / gRPC -
After some investigation, it seems that the emulator is not using HTTP/2 and therefore not able to support the gRPC protocol required for...
Read more >The Cloud Firestore emulator is not running so database ...
Managed to have the local cloud functions working with the real remote DB by making sure of the following: run firebase login and...
Read more >Cloud Firestore API - Firebase - Google
GetLocation, Gets information about a location. ListLocations, Lists information about the supported locations for this service.
Read more >gcloud emulators firestore | Google Cloud CLI Documentation
API-first integration to connect existing data and applications. ... Solution to bridge existing care systems and apps on Google Cloud. ... No-code developmentΒ ......
Read more >Long cold start times for Node.js programs with gRPC ...
512MB functions saw around 750 ms load times for @google-cloud/firestore . ... Testing isn't easy as of now as there is no local...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The tip in this comment to turn on a VPN helped me fix this issue. My specific issue was that my Flutter app when used on a mobile device was not connecting to my local Firestore emulator, emitting the same errors here. Maybe the root cause is because I have a multi-router config with DHCP on π€·
Steps to my fix:
Option 1:
firebase.json
in the directory for your Firebase project e.g.192.168.x.xx
. e.g.FirebaseFirestore.instance.useFirestoreEmulator('192.168.x.xx', 8080);
Option 2:
firebase.json
for your Firestore emulator1.tcp.ngrok.io:[port]
. e.g.FirebaseFirestore.instance.useFirestoreEmulator('1.tcp.ngrok.io', [port]);
Remember to make sure your Firestore emulatorβs security rules are set up to allow the queries youβre making. Also make sure that your Flutter app is connecting to the same project-id that the Firestore emulator is running for. e.g. if youβre using the Flutterfire CLI to configure Firebase for your Flutter project, make sure the project-ids in the generated
firebase_options.dart
in your Flutter project direcotry match the project-id in the.firebaserc
in your Firebase projectβs directory.Going to share my implementation as it adds in the specific detail for configuring ngrok with Firebase Emulator with Android project building to device. I experienced all the above issues as well as some others. But the above post solved the main issue, which was I was setting ngrok to expect use of its http protocol from firebstore, but infact firestore was expecting tcp.
I launched the emulator like so.
Below is my NGrok yml file. Note that the main fix here was to set the firestore proto to tcp.
Launched ngrok from same directory as my firebase cloud function project. Though obviously you can launch from anywhere.
Then in a suitably early place for intialising FirebaseAuth, and FirebaseFireStore in my Flutter project. (i have this in main_dev.dart for my dev flavour.
I had followed the above suggestions but lazily missed out the fact that i had to change the proto to tcp in my config file. An intermediate error i recieved, due to my half assed attempt to resolve the issue was.
This post made me realise i was passing http as the protocol when it was actually checking for tcp.
Anyway, i hope this helps others spend less time getting firebase up and running with Ngrok.
Note: I believe that both the following worked, in terms of an android device being able to work with the emulator. As long as they are on the same network.