I have a react native app, which i am developing using Expo. In my project, i run firebase firestore emulator and I want to connect my application to the emulator. I use the expo GO app on my phone and call the following function (after initialising the app):
connectFirestoreEmulator(db, "127.0.0.1", 8080);
When i try to add data to the firestore using:
const joinDesqr = await addDoc(colRef, {
userID: userID,
level: level,
timeslots: timeslots,
days: days,
})
i get a warning like this, and the data is not inserted to the firestore emulator database:
WARN [2023-02-21T17:29:08.454Z] @firebase/firestore: Firestore (9.17.1): Connection WebChannel transport errored: {"defaultPrevented": false, "g": {"A": true, "J": null, "R": [Circular], "g": {"$": true, "$a": 5000, "A": 0, "B": null, "C": 0, "Ca": null, "D": "gsessionid", "Ea": -1, "F": [U], "Fa": 0, "G": 0, "Ga": false, "H": true, "Ia": [ud], "J": "", "K": undefined, "L": false, "M": true, "O": true, "P": false, "R": 0, "U": [Object], "V": -1, "W": 70081, "Y": "http://127.0.0.1:8080/google.firestore.v1.Firestore/Write/channel", "aa": 0, "ab": false, "ba": false, "bb": false, "cb": 2, "eb": 1, "fb": 10000, "g": null, "h": [pd], "i": [Array], "j": [Sb], "l": [Z], "la": [Object], "m": null, "ma": undefined, "na": null, "o": null, "oa": null, "s": null, "sa": 0, "u": null, "ua": undefined, "v": null, "va": null, "wa": 600000}, "h": {"database": "projects/padel-q/databases/(default)"}, "i": {"g": [Object], "h": 4, "src": [Circular]}, "j": {"g": [Circular]}, "l": "http://127.0.0.1:8080/google.firestore.v1.Firestore/Write/channel", "o": undefined, "s": false, "v": true}, "status": 1, "target": {"A": true, "J": null, "R": [Circular], "g": {"$": true, "$a": 5000, "A": 0, "B": null, "C": 0, "Ca": null, "D": "gsessionid", "Ea": -1, "F": [U], "Fa": 0, "G": 0, "Ga": false, "H": true, "Ia": [ud], "J": "", "K": undefined, "L": false, "M": true, "O": true, "P": false, "R": 0, "U": [Object], "V": -1, "W": 70081, "Y": "http://127.0.0.1:8080/google.firestore.v1.Firestore/Write/channel", "aa": 0, "ab": false, "ba": false, "bb": false, "cb": 2, "eb": 1, "fb": 10000, "g": null, "h": [pd], "i": [Array], "j": [Sb], "l": [Z], "la": [Object], "m": null, "ma": undefined, "na": null, "o": null, "oa": null, "s": null, "sa": 0, "u": null, "ua": undefined, "v": null, "va": null, "wa": 600000}, "h": {"database": "projects/padel-q/databases/(default)"}, "i": {"g": [Object], "h": 4, "src": [Circular]}, "j": {"g": [Circular]}, "l": "http://127.0.0.1:8080/google.firestore.v1.Firestore/Write/channel", "o": undefined, "s": false, "v": true}, "type": "c"}
If i don't run the ConnectFirebaseEmulator()
function, the application perfectly adds data to my real firestore database. My reasoning is that i should put the IP of my actual computer where the local emulator is running. The default value is "localhost" instead, which is not working either.
I have tried experimentalForceLongPolling as some threads suggest, but without success:
const db = initializeFirestore(firebaseConfig, {
experimentalForceLongPolling: true,
});