firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.84k stars 889 forks source link

@firebase/firestore: Firestore (7.17.2): Could not reach Cloud Firestore backend - Error #3584

Closed danielHype closed 4 years ago

danielHype commented 4 years ago

[REQUIRED] Describe your environment

[REQUIRED] Describe the problem

Steps to reproduce:

Since a few days we are getting an error while trying to communicate via Firebase/ Firestore. However, the issue only comes in our localhost, as soon as we build and deploy on our server everything works fine. Please see the issue getting logged into my console.

image

image

Furthermore:

[2020-08-07T12:34:27.214Z]  @firebase/firestore: Firestore (7.17.2): FirestoreClient Initializing. user= 4iMbM6Fy7nUq41u5rDYfPTNfQ963
index.esm.js?abfd:106 [2020-08-07T12:34:27.220Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Get next mutation batch
index.esm.js?abfd:106 [2020-08-07T12:34:27.222Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Get next mutation batch
index.esm.js?abfd:106 [2020-08-07T12:34:27.227Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Allocate target
index.esm.js?abfd:106 [2020-08-07T12:34:27.229Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Execute query
index.esm.js?abfd:106 [2020-08-07T12:34:27.229Z]  @firebase/firestore: Firestore (7.17.2): IndexFreeQueryEngine Using full collection scan to execute query: Query(target=Target(othergame, filters: [userId == 4iMbM6Fy7nUq41u5rDYfPTNfQ963], orderBy: [__name__ (asc)]); limitType=F)
index.esm.js?abfd:106 [2020-08-07T12:34:27.232Z]  @firebase/firestore: Firestore (7.17.2): FirebaseCredentialsProvider getToken aborted due to token change.
index.esm.js?abfd:106 [2020-08-07T12:34:27.233Z]  @firebase/firestore: Firestore (7.17.2): Connection Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/7.17.2","Content-Type":"text/plain","Authorization":"Bearer <omitted>"},"messageUrlParams":{"database":"projects/<project>/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":true,"httpHeadersOverwriteParam":"$httpHeaders"}
index.esm.js?abfd:106 [2020-08-07T12:34:27.234Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Allocate target
index.esm.js?abfd:106 [2020-08-07T12:34:27.235Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Execute query
index.esm.js?abfd:106 [2020-08-07T12:34:27.235Z]  @firebase/firestore: Firestore (7.17.2): IndexFreeQueryEngine Using full collection scan to execute query: Query(target=Target(users, filters: [userId == <user id>], orderBy: [__name__ (asc)]); limitType=F)
index.esm.js?abfd:106 [2020-08-07T12:34:27.236Z]  @firebase/firestore: Firestore (7.17.2): RemoteStore RemoteStore received new credentials
index.esm.js?abfd:106 [2020-08-07T12:34:27.239Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Get next mutation batch
index.esm.js?abfd:106 [2020-08-07T12:34:27.239Z]  @firebase/firestore: Firestore (7.17.2): Connection Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/7.17.2","Content-Type":"text/plain","Authorization":"Bearer <jwt left our for privavy purposes>},"messageUrlParams":{"database":"projects/<project>/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":true,"httpHeadersOverwriteParam":"$httpHeaders"}
index.esm.js?abfd:106 [2020-08-07T12:34:27.240Z]  @firebase/firestore: Firestore (7.17.2): PersistentStream stream callback skipped by getCloseGuardedDispatcher.
index.esm.js?abfd:106 [2020-08-07T12:34:27.244Z]  @firebase/firestore: Firestore (7.17.2): Connection Opening WebChannel transport.
index.esm.js?abfd:106 [2020-08-07T12:34:27.245Z]  @firebase/firestore: Firestore (7.17.2): Connection WebChannel sending: {"database":"projects/<project>/databases/(default)","addTarget":{"query":{"structuredQuery":{"from":[{"collectionId":"othergame"}],"where":{"fieldFilter":{"field":{"fieldPath":"userId"},"op":"EQUAL","value":{"stringValue":"4iMbM6Fy7nUq41u5rDYfPTNfQ963"}}},"orderBy":[{"field":{"fieldPath":"__name__"},"direction":"ASCENDING"}]},"parent":"projects/<project>/databases/(default)/documents"},"targetId":2}}
index.esm.js?abfd:106 [2020-08-07T12:34:27.245Z]  @firebase/firestore: Firestore (7.17.2): Connection WebChannel sending: {"database":"projects/<project>/databases/(default)","addTarget":{"query":{"structuredQuery":{"from":[{"collectionId":"users"}],"where":{"fieldFilter":{"field":{"fieldPath":"userId"},"op":"EQUAL","value":{"stringValue":"4iMbM6Fy7nUq41u5rDYfPTNfQ963"}}},"orderBy":[{"field":{"fieldPath":"__name__"},"direction":"ASCENDING"}]},"parent":"projects/l<project>t/databases/(default)/documents"},"targetId":4}}
[2020-08-07T12:19:45.762Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Release target
index.esm.js?abfd:106 [2020-08-07T12:19:45.763Z]  @firebase/firestore: Firestore (7.17.2): MemoryPersistence Starting transaction: Release target
index.esm.js?abfd:106 [2020-08-07T12:19:45.764Z]  @firebase/firestore: Firestore (7.17.2): Connection Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/7.17.2","Content-Type":"text/plain","Authorization":"Bearer <jsw token left out for privacy purposes>"},"messageUrlParams":{"database":"projects/<our project>/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":true,"httpHeadersOverwriteParam":"$httpHeaders"}

As you can see in the results, I tried different things: At first, forceLongPolling, logging extensive logging and trying different firebase versions. Updating to the newest version, which many people helped, did not help me.

I think code reproduction may work, but should not be needed here as this is probably an easyfix.

Still, googling and putting many hours in did not help for me thus I am seeking help here.

If more information is needed, please inform me and i am very happy to provide more information.

I am not sure if this may be subject to changes made by chrome due to new enforced CORS and cookie policy. As the screenshot suggest, I am having a problem with the CORS Policy. However, if yes, how can I enforce CORS with firebase?

I am not using API Calls, I am using the firebase functions.

Nithanaroy commented 4 years ago

Thanks firebase team for creating such a wonderful software and for making it open source & free for simple usage.

I am facing a similar CORS issue on Chrome 84, Safari and Firefox with 7.9.1, 7.9.3, 7.9.3 and 7.17.2 versions of firebase app, and storage on both localhost and on a website deployed via Google app script.

I enabled CORS on my storage bucket as shared in https://stackoverflow.com/a/37765371/1585523. However it was mentioned in https://cloud.google.com/storage/docs/cross-origin#client-side-support that such a thing is not necessary.

schmidt-sebastian commented 4 years ago

@danielHype Can you confirm that you are indeed using version 7.12.2 and not 7.17.2? We made changes in our networking stack in version 7.17.2 and I would like to figure out if this is a possible regression.

From the logs it looks like you are using the latest version 7.17.2. Do you see similar behavior in version 7.17.1? We made changes in our networking stack in version 7.17.2 and I would like to figure out if this is a possible regression. So far, I have not been able to see this issue locally.

schmidt-sebastian commented 4 years ago

@danielHype I talked to the maintainer of the WebChannel library about this issue. It turns out that we need a couple more things to look at this. Can you send us the URL and the request/response headers for the failed requests as recorded by the Chrome debugger (specifically the URL and Origin header for the initial POST handshake request)? Thanks!

google-oss-bot commented 4 years ago

Hey @danielHype. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

asaduzzaman69 commented 4 years ago

i have the same issue...please solve this isse..getting this error for calling get method in documentRef..please google solve this

Screenshot_95

google-oss-bot commented 4 years ago

Hey @danielHype. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

chris-ryu commented 4 years ago

I have same error 7.19.1 React Native expo SDK 38

var firebaseConfig = { apiKey: "mykey", authDomain: "react-native-chat-8b961.firebaseapp.com", databaseURL: "https://react-native-chat-8b961.firebaseio.com", projectId: "react-native-chat-8b961", storageBucket: "react-native-chat-8b961.appspot.com", messagingSenderId: "366682905206", appId: "1:366682905206:web:537cc31fdad7d4be6c1d57", measurementId: "G-8PRQ8YNTH3", };

[2020-08-29T02:09:26.941Z] @firebase/firestore:, Firestore (7.19.1): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=not-found]: The project react-native-chat-8b961 does not exist or it does not contain an active Cloud Datastore or Cloud Firestore database. Please visit http://console.cloud.google.com to create a project or https://console.cloud.google.com/datastore/setup?project=react-native-chat-8b961 to add a Cloud Datastore or Cloud Firestore database. Note that Cloud Datastore or Cloud Firestore always have an associated App Engine app and this app must not be disabled. 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.

hsubox76 commented 4 years ago

Even though the original issue opener hasn't responded, I see other users have the issue and I think the Firestore team still requires this additional information to help solve the problem:

@danielHype I talked to the maintainer of the WebChannel library about this issue. It turns out that we need a couple more things to look at this. Can you send us the URL and the request/response headers for the failed requests as recorded by the Chrome debugger (specifically the URL and Origin header for the initial POST handshake request)? Thanks!

Can any of the other users having this problem provide this info? I believe they need the actual POST request details, not just error logs.

chris-ryu commented 4 years ago

@hsubox76 Here is my http dump.

1.har.zip

Request origin: file:// sec-fetch-dest: empty x-goog-api-client: gl-js/ fire/7.8.1 user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) ReactNativeDebugger/0.11.3 Chrome/80.0.3987.165 Electron/8.2.5 Safari/537.36 content-type: application/x-www-form-urlencoded

count=1&ofs=0&req0_data=%257B%2522database%2522%253A%2522projects%252Freact-native-chat-8b961%252Fdatabases%252F%28default%29%2522%252C%2522addTarget%2522%253A%257B%2522query%2522%253A%257B%2522structuredQuery%2522%253A%257B%2522from%2522%253A%255B%257B%2522collectionId%2522%253A%2522chats%2522%257D%255D%252C%2522orderBy%2522%253A%255B%257B%2522field%2522%253A%257B%2522fieldPath%2522%253A%2522name%2522%257D%252C%2522direction%2522%253A%2522ASCENDING%2522%257D%255D%257D%252C%2522parent%2522%253A%2522projects%252Freact-native-chat-8b961%252Fdatabases%252F%28default%29%252Fdocuments%2522%257D%252C%2522targetId%2522%253A2%257D%257D

Response :status: 200 date: Tue, 01 Sep 2020 12:06:24 GMT content-encoding: gzip x-content-type-options: nosniff server: ESF x-frame-options: SAMEORIGIN content-type: text/plain; charset=utf-8 cache-control: private x-client-wire-protocol: h2 x-http-session-id: HKkOstWt4zadr9UdM8ZWKV3ArtDhKEHV alt-svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43" content-length: 71 x-xss-protection: 0

51 [[0,["c","FI0waj_NK_Ntfq2dpKr3jQ","",8,12,30000]]]

hsubox76 commented 4 years ago

In your case (unlike the original post), I noticed the error message contained this text:

The project react-native-chat-8b961 does not exist or it does not contain an active Cloud Datastore or Cloud Firestore database. Please visit http://console.cloud.google.com to create a project or https://console.cloud.google.com/datastore/setup?project=react-native-chat-8b961 to add a Cloud Datastore or Cloud Firestore database.

Just wanted to double check, did you create a Firestore database in the console for this project?

chris-ryu commented 4 years ago

@hsubox76 I just found out that "Realtime" and "Firestore" are different things. I created "Realtime" and tried to access "Firestore". Thank you for your double check :)

hsubox76 commented 4 years ago

Glad that helped! If anyone is still having the initial problem in this issue, can you please provide the details @schmidt-sebastian asked for above? I can re-quote:

@danielHype I talked to the maintainer of the WebChannel library about this issue. It turns out that we need a couple more things to look at this. Can you send us the URL and the request/response headers for the failed requests as recorded by the Chrome debugger (specifically the URL and Origin header for the initial POST handshake request)? Thanks!

If not, I'll leave the "needs-info" tag up and let the bot auto-close the issue if there are no responses after a certain amount of time.

google-oss-bot commented 4 years ago

Hey @danielHype. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 4 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@danielHype if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.