'Firestore not connected using Expo-dev-client
If I use expo start
, my firestore work fine in Expo Go. But when i use expo start --dev-client
it stop working. I already tried using EAS using EAS Migration Guide, but the same error happen.
Here is the Error message:
@firebase/firestore:, Firestore (8.2.2): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
at node_modules/@firebase/logger/dist/index.cjs.js:98:8 in defaultLogHandler
at node_modules/@firebase/logger/dist/index.cjs.js:212:8 in Logger.prototype.error
at node_modules/@firebase/firestore/dist/rn/prebuilt.rn-f9cd27ba.js:60:8 in P
at node_modules/@firebase/firestore/dist/rn/prebuilt.rn-f9cd27ba.js:8135:20 in <global>
at node_modules/@firebase/firestore/dist/rn/prebuilt.rn-f9cd27ba.js:8105:8 in stream.onMessage$argument_0
at node_modules/@firebase/firestore/dist/rn/prebuilt.rn-f9cd27ba.js:5218:67 in Ds#constructor
at node_modules/@firebase/firestore/dist/rn/prebuilt.rn-f9cd27ba.js:11781:54 in <global>
@firebase/firestore:, Firestore (8.2.2): Connection, WebChannel transport errored
There is no problem with my connection, because the API in the App is still working.
is there an additional setting for EAS or expo-dev-client?
Here is how i start my firebase
class FirebaseServices {
static handleFirebaseConfig() {
var firebaseConfig = {
apiKey: 'API_KEY',
authDomain: "firebaseapp.com",
projectId: "PROJECT_ID",
storageBucket: "STORAGE",
messagingSenderId: "ID",
appId: "APP_ID",
measurementId: "ID"
};
let app;
if (firebase.apps.length === 0) {
app = firebase.initializeApp(firebaseConfig)
}
else {
app = firebase.app();
}
return app;
}} const db = FirebaseServices.handleFirebaseConfig().firestore()
Solution 1:[1]
I solve this using the answer from the thread, by adding experimentalForceLongPolling.
class FirebaseServices {
static handleFirebaseConfig() {
var firebaseConfig = {
apiKey: 'API_KEY',
authDomain: "firebaseapp.com",
projectId: "PROJECT_ID",
storageBucket: "STORAGE",
messagingSenderId: "ID",
appId: "APP_ID",
measurementId: "ID"
};
let app;
if (firebase.apps.length === 0) {
app = firebase.initializeApp(firebaseConfig)
firebase().firestore().settings({
experimentalForceLongPolling: true, // this line
useFetchStreams: false, // and this line
})
}
else {
app = firebase.app();
}
return app;
}
}
const db = FirebaseServices.handleFirebaseConfig().firestore()
And i already upgrade my firebase to v9, so it change to something like this
const app = initializeApp(firebaseConfig);
const firestoreDB = initializeFirestore(app, {
experimentalForceLongPolling: true,
useFetchStreams: false,
})
export const dbFs = getFirestore(app);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | muhammad ripqi |