Firebase-js-sdk: @firebase/firestore: Firestore (5.5.9): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.

Created on 8 Jan 2019  路  5Comments  路  Source: firebase/firebase-js-sdk

I have a react native app that uses Firebase/firestore. For uploading images, I am using "react-native-fetch-blob" to create a Blob.

I am trying to fetch doc from firestore, but my app is blocked and not getting any response from firestore (not catch / nothing => just passing thru the code).

Is there anything I can do for getting docs from firestore?

Below is my code

import firebase from "../../../firebaseConfig";
import RNFetchBlob from "react-native-fetch-blob";

// Prepare Blob support
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
const Blob = RNFetchBlob.polyfill.Blob;
const fs = RNFetchBlob.fs;
window.Blob = Blob;
const originalXMLHttpRequest = window.XMLHttpRequest;
const originalBlob = window.Blob;

var firebaseUid = "";

componentDidMount = async () => {
firebaseUid = await firebase.auth().currentUser.uid;
this.getMyStory();
};

getMyStory = async () => {
window.XMLHttpRequest = originalXMLHttpRequest;
window.Blob = originalBlob;
var docRef = await firebase
.firestore()
.collection("demo")
.doc(firebaseUid)
.collection("ArrayDoc");
docRef
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log(doc.id, " => ", doc.data());
});
})
.catch(error => {
console.log("error", JSON.stringify(error));
});
};

screenshot 2019-01-07 at 5 19 52 pm

firestore question

All 5 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

I have the same error.

I think there's a known incompatibility with react-native-fetch-blob. See https://github.com/wkh237/react-native-fetch-blob/issues/634 and the workaround suggested here. I would comment on that issue (or maybe open a new one since that one is closed), as I think this is ultimately a problem with react-native-fetch-blob.

This is what I did and it worked for me:

First store window.XMLHttpRequest in a variable
const tempWindowXMLHttpRequest = window.XMLHttpRequest;

Now for RN Fetch Blob, use it's settings
// Prepare Blob support
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest;
const Blob = RNFetchBlob.polyfill.Blob;
const fs = RNFetchBlob.fs;
window.Blob = Blob;
const originalXMLHttpRequest = window.XMLHttpRequest;
const originalBlob = window.Blob;

Then just before making your Firestore call - replace window.XMLHttpRequest with it's old state:
window.XMLHttpRequest = tempWindowXMLHttpRequest;

Hope this would help!

You should verify your proxy and/or firewall ports because firebase uses websockets.
I have the same error , it was working when i'm not in proxy and blocked when i am in proxy specially for Cloud Firestore.

Was this page helpful?
0 / 5 - 0 ratings