Skip to content

Firebase error : failed to get document because the client is offline #5836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yunesuk opened this issue Dec 24, 2021 · 4 comments
Closed

Firebase error : failed to get document because the client is offline #5836

yunesuk opened this issue Dec 24, 2021 · 4 comments

Comments

@yunesuk
Copy link

yunesuk commented Dec 24, 2021

[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);  
          });
@argzdev
Copy link

argzdev commented Dec 24, 2021

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!

@yunesuk
Copy link
Author

yunesuk commented Dec 24, 2021

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.

@argzdev
Copy link

argzdev commented Dec 24, 2021

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.

@yunesuk yunesuk closed this as completed Dec 25, 2021
@yunesuk
Copy link
Author

yunesuk commented Dec 25, 2021

probleme solved by using https://rnfirebase.io/ package
thanks

@firebase firebase locked and limited conversation to collaborators Jan 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants