Firebase error : failed to get document because the client is offline
[REQUIRED] Describe your environment
- Operating System version: windows 10
- Browser version: react native 0.66.4
- Firebase SDK version: 9.6.1
- Firebase Product: database , firestore (auth, database, storage, etc)
[REQUIRED] Describe the problem
im using firebase v9 with react native project , it gives me error while trying to get or set data in firestore , my code is valide , the confuse one is auth working fine but firestore gives me error that my device is not connected to network intenet , i tested it in my real device and android emulator it gives me the same error from wednesday, im stuck in this probleme plead
Relevant Code:
//firebase.js
import {initializeApp} from 'firebase/app';
import {getFirestore} from 'firebase/firestore';
import {getAuth} from 'firebase/auth';
const firebaseConfig = {
//config here..
};
const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);
createUserWithEmailAndPassword(auth, email, password)
.then(userCredential => {
setDoc(doc(db, 'users', userCredential.uid), {
username: username,
email: userCredential.email,
}).catch(error => {
Errmsg(error.message);
});
})
.catch(error => {
Errmsg(error.message);
});
//getting data
getDoc(doc(db, 'users', currentUser.uid))
.then(docSnap => {
if (docSnap.exists()) {
console.log('Document:');
} else {
console.log('No such document!');
}
})
.catch(e => {
console.log(e.message);
});
Hi @YunsGeek, thanks for reporting. It looks like this issue is similar to #5667. Could you try checking if the provided solution in that issue is able to resolve the problem? If not, could you attach details of the log so we can investigate this further? Thanks!
thank you , but it does not work and still the same error and the result is :
ERROR :
[2021-12-24T10:45:44.855Z] @firebase/firestore: Firestore (9.6.1): 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.
LOG : Failed to get document because the client is offline.
There is definitely something odd here, even though you've encountered the same issue. With that said, could you provide us with an MCVE and connection logs? You can enable detailed debug logging using firebase.firestore.setLogLevel('debug') so we can investigate this further, please do remove any PII (if there are any), It'll greatly help us to pinpoint where the issue lies.
probleme solved by using https://rnfirebase.io/ package thanks