firebase / firebase-js-sdk

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

Kaspersky antivirus breaks Firestore ("Could not reach Cloud Firestore backend.") #1190

Open h2u opened 6 years ago

h2u commented 6 years ago

UPDATE [by @mikelehen 2018/10/21]: This issue has morphed into specifically being about the Kaspersky antivirus software blocking Firestore. Please open a separate bug if you're encountering issues without Kaspersky.

Environment

Problem

Im using Firestore with Ionic (Angularfire2 package). Any collection or doc gives error but after ~10 seconds it gives data. Auth works without any problems.

Error:

@firebase/firestore: Firestore (5.0.4): 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.

Created new Firebase Project and new Ionic project, installed packages, tried to make collection, shows same error.

"angularfire2": "^5.0.0-rc.12",
"firebase": "^5.4.2",
"rxjs": "^6.3.1",
"rxjs-compat": "^6.3.1",

The code im trying to run:

  db.collection('categories').valueChanges().subscribe(data => {
    console.log(data);
  });

And the console output:

[2018-09-02T09:05:36.388Z]  @firebase/firestore: Firestore (5.0.4) [FirestoreClient]: Initializing. user= null
index.esm.js:65 [2018-09-02T09:05:36.389Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Start LocalStore
index.esm.js:65 [2018-09-02T09:05:36.391Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Get last stream token
index.esm.js:65 [2018-09-02T09:05:36.392Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Get next mutation batch
index.esm.js:65 [2018-09-02T09:05:36.394Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Allocate query
index.esm.js:65 [2018-09-02T09:05:36.396Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Execute query
index.esm.js:65 [2018-09-02T09:05:36.396Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Remote document keys
index.esm.js:65 [2018-09-02T09:05:36.399Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1beta1.Firestore/Listen/channel [object Object]
index.esm.js:65 [2018-09-02T09:05:36.415Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: Opening WebChannel transport.
index.esm.js:65 [2018-09-02T09:05:36.418Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel sending: {"database":"projects/app-17s82/databases/(default)","addTarget":{"query":{"structuredQuery":{"from":[{"collectionId":"categories"}],"orderBy":[{"field":{"fieldPath":"__name__"},"direction":"ASCENDING"}]},"parent":"projects/app-17s82/databases/(default)"},"targetId":2}}
index.esm.js:65 [2018-09-02T09:05:36.683Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel transport opened.
index.esm.js:77 [2018-09-02T09:05:47.151Z]  @firebase/firestore: Firestore (5.0.4): 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.
index.esm.js:65 [2018-09-02T09:06:06.989Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"targetChange":{"targetChangeType":"ADD","targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:06.991Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:32.276692Z","fields":{"image":{"stringValue":"categories/a.jpg"},"lang_key":{"stringValue":"A"},"order":{"integerValue":"10"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/54Nxy6OOm4yantdzUDXu","updateTime":"2018-08-27T18:08:13.536914Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:06.994Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:31.537482Z","fields":{"image":{"stringValue":"categories/b.jpg"},"lang_key":{"stringValue":"B"},"order":{"integerValue":"6"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/8xNLqdlqqflMbu6Y8P8k","updateTime":"2018-08-26T18:59:31.537482Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:06.996Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:30.510370Z","fields":{"image":{"stringValue":"categories/c.jpg"},"lang_key":{"stringValue":"C"},"order":{"integerValue":"1"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/9UFJB2KAhFij6tcKaVFK","updateTime":"2018-08-26T18:59:30.510370Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:06.997Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:31.944855Z","fields":{"image":{"stringValue":"categories/d.jpg"},"lang_key":{"stringValue":"D"},"order":{"integerValue":"8"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/B76lIXguh3hFZcnXLybt","updateTime":"2018-08-26T18:59:31.944855Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:06.999Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:31.144277Z","fields":{"image":{"stringValue":"categories/e.jpg"},"lang_key":{"stringValue":"E"},"order":{"integerValue":"4"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/Dh10cOAFtywBF1nD6Oit","updateTime":"2018-08-26T18:59:31.144277Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.000Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:32.469426Z","fields":{"image":{"stringValue":"categories/a1.jpg"},"lang_key":{"stringValue":"A1"},"order":{"integerValue":"11"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/TaMikooiiCQSVcgvdUcM","updateTime":"2018-08-26T18:59:32.469426Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.002Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:31.341506Z","fields":{"image":{"stringValue":"categories/a2.jpg"},"lang_key":{"stringValue":"A2"},"order":{"integerValue":"5"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/bNk3WF02m9QC72W9CNFD","updateTime":"2018-08-26T18:59:31.341506Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.003Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:32.137302Z","fields":{"image":{"stringValue":"categories/a3.jpg"},"lang_key":{"stringValue":"A3"},"order":{"integerValue":"9"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/e0ffuG7GM1ikxdksjihZ","updateTime":"2018-08-26T18:59:32.137302Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.004Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:30.946686Z","fields":{"image":{"stringValue":"categories/a4.jpg"},"lang_key":{"stringValue":"A4"},"order":{"integerValue":"3"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/fgxGcgA9Ye3sue2FkNzo","updateTime":"2018-08-26T18:59:30.946686Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.006Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:31.747379Z","fields":{"image":{"stringValue":"categories/a5.jpg"},"lang_key":{"stringValue":"A5"},"order":{"integerValue":"7"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/fnSThPm2vbDdO8w5fIA1","updateTime":"2018-08-26T18:59:31.747379Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.008Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:30.294481Z","fields":{"image":{"stringValue":"categories/b1.jpg"},"lang_key":{"stringValue":"WORK"},"B1":{"integerValue":"0"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/tDQRayJlugtkIvIdtqGb","updateTime":"2018-08-26T18:59:30.294481Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.010Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"documentChange":{"document":{"createTime":"2018-08-26T18:59:30.712287Z","fields":{"image":{"stringValue":"categories/b2.jpg"},"lang_key":{"stringValue":"B2"},"order":{"integerValue":"2"},"visible":{"booleanValue":true}},"name":"projects/app-17s82/databases/(default)/documents/categories/tymqkjiII9sEKWxR9Cnw","updateTime":"2018-08-26T18:59:30.712287Z"},"targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.011Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"targetChange":{"readTime":"2018-09-02T10:06:51.233599Z","resumeToken":"CgkIv6qFq4mc3QI=","targetChangeType":"CURRENT","targetIds":[2]}}
index.esm.js:65 [2018-09-02T09:06:07.011Z]  @firebase/firestore: Firestore (5.0.4) [Connection]: WebChannel received: {"targetChange":{"readTime":"2018-09-02T10:06:51.233599Z","resumeToken":"CgkIv6qFq4mc3QI="}}
index.esm.js:65 [2018-09-02T09:06:07.022Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Get last remote snapshot version
index.esm.js:65 [2018-09-02T09:06:07.026Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Apply remote event
index.esm.js:65 [2018-09-02T09:06:07.043Z]  @firebase/firestore: Firestore (5.0.4) [MemoryPersistence]: Starting transaction: Garbage collection
app.provider.ts:62 (12) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
nguyenviettung7691 commented 6 years ago

Encountered the same error just yesterday when querying data. Seems to be a problem with Firestore not able to get data.

Environment Operating System version: Windows 10 Browser version: Chrome 68.0.3440.106 Firebase SDK version: 5.0.4 Firebase Product: store

Packages

"dependencies": {
    "animated-number-vue": "^0.1.2",
    "firebase": "^5.0.4",
    "highcharts": "^6.1.0",
    "mdi": "^2.2.43",
    "raven-js": "^3.26.2",
    "vue": "^2.5.16",
    "vue-add-to-calendar": "^1.0.4",
    "vue-fullscreen": "^2.1.3",
    "vue-highcharts": "0.0.10",
    "vue-infinite-scroll": "^2.0.2",
    "vue-progressbar": "^0.7.5",
    "vue-router": "^3.0.1",
    "vue-swatches": "^1.0.1",
    "vuefire": "^1.4.5",
    "vuetify": "^1.0.17",
    "xlsx": "^0.13.0"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.51",
    "@babel/plugin-syntax-jsx": "^7.0.0-beta.51",
    "@babel/plugin-transform-runtime": "^7.0.0-beta.51",
    "@babel/preset-env": "^7.0.0-beta.51",
    "@babel/preset-stage-2": "^7.0.0-beta.51",
    "@vue/cli": "^3.0.0-rc.2",
    "@vue/cli-init": "^3.0.0-rc.2",
    "autoprefixer": "^8.3.0",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^8.0.0-beta.3",
    "babel-plugin-transform-vue-jsx": "^4.0.1",
    "chalk": "^2.4.1",
    "copy-webpack-plugin": "^4.5.1",
    "css-loader": "^0.28.11",
    "file-loader": "^1.1.11",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "html-webpack-plugin": "^3.2.0",
    "less": "^3.0.4",
    "less-loader": "^4.1.0",
    "mini-css-extract-plugin": "^0.4.0",
    "node-less": "^1.0.0",
    "node-notifier": "^5.2.1",
    "optimize-css-assets-webpack-plugin": "^4.0.0",
    "ora": "^2.0.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.1.0",
    "postcss-loader": "^2.1.5",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.2",
    "semver": "^5.5.0",
    "shelljs": "^0.8.1",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^1.0.1",
    "vue-loader": "^15.0.3",
    "vue-style-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.6.0",
    "webpack-bundle-analyzer": "^2.13.1",
    "webpack-cli": "^3.0.7",
    "webpack-dev-server": "^3.1.3",
    "webpack-merge": "^4.1.3"
  },
banazak commented 6 years ago

+1

d-yoshi commented 6 years ago

I think that anti-virus software is causing this error as one of the causes.

mickev36 commented 6 years ago

@h2u Is the problem random or occuring for each request ? We have a similar issue here for a similar setup (firestore 5.0.4, chrome), and this problem occurs randomly, blocking all requests after the first fail. Problem is happening in production for our users. the big difference with your stack is that we use firestore in a web browser context, not Ionic (even though it should be pretty similar).

I managed to find out that installing the Firebug Lite Chrome extension makes the problem appear almost immediately and consistently. The "XHR Listener" used by firebug (patching the XMLHttpRequest with a wrapper) is causing the issue. Unfortunately, out users/clients encounter the problem without Firebug Lite installed, so the root cause must be somewhere else.

Any help would be appreciated.

EDIT : In the meantime, we'll switch to the REST API.

h2u commented 6 years ago

@mickev36 , the problem is random but happens very recently.

Maybe @d-yoshi is right, it's anti-virus. Had no chance to work on project without anti-virus on Windows.

At the moment Im working on MacOS on the same network as Windows was and have no problems with connection.

banazak commented 6 years ago

In our case it was also the anti-virus (Kaspersky). It worked without it.

h2u commented 6 years ago

I feel that I have same problem because I have Kaspersky as well.

d-yoshi commented 6 years ago

I'm also using Kaspersky and I encountered this problem frequently. I don't know any solution other than invalidating Kaspersky for now. 😢

nguyenviettung7691 commented 6 years ago

I can confirm that this bug is very random, happened recently, and I don't have any antivirus software, except the default Windows Defender, which I can't turn off because of company policy.

gamsterx commented 6 years ago

Same problem here since a week or two. Also Kaspersky... When I first load the page the following error message is output (every single time):

@firebase/firestore: Firestore (5.5.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.

after 30+ seconds the data from firestore finally loads

XHR finished loading: POST "https://firestore.googleapis.com/google.firestore.v1beta1.Firestore/Listen/channel..."

If I reload the page and navigate to another page, where firestore data is loaded, I immediately get the data back without the error. 😕

If I pause Kaspersky the error does not occurr.

...
"@angular/fire": "^5.0.0",
"firebase": "^5.5.0",
...
ThiloKielmann commented 6 years ago

Same here. My users (in web browsers) get the same message about firestore not being able to reach its backend once Kaspersky is activated on a Win 10 machine...

Geoffrey-Pliez commented 6 years ago

Same for me but only on IE 11.

But if I load the page, navigate immediatly to another page and then return to "firestore page", data is loaded without the error.

In my case, it seems like it's a conflict with webcomponents.js because when I do not put it, it works

chunkydonut21 commented 6 years ago

In my case it was due to Rn-fetch-blob library. I moved

const Blob = RNFetchBlob.polyfill.Blob
const fs = RNFetchBlob.fs
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
window.Blob = Blob

inside the async function rather then defining it at the top. And it solved.

rodrigomata commented 6 years ago

+1

gamsterx commented 6 years ago

So I just generated a new angular project and only used the firebase sdk (5.5.2) to see if some other package causes the issue. It had the same outcome.

I currently have Kaspersky Internet Security 2018 installed. When I switch off the web anti virus feature the error does not occur! I immediately get all my desired data back from firestore.

My current workaround for development is to leave web anti virus running and to add the following url to the tursted websites within the web anti virus settings of kaspersky:

https://firestore.googleapis.com/*

This seems to work, but would only be acceptable for development.

mikelehen commented 6 years ago

@gamsterx It would be very helpful if you could report this as a bug to Kaspersky. Unfortunately there isn't much that we can do if 3rd-party software is blocking our network access.

ddesna commented 6 years ago

I'm working on mac os (without any Kaspersky 😆) and I have the same problem:

@firebase/firestore: Firestore (5.5.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=failed-precondition]: The Cloud Firestore API is not available for Cloud Datastore projects.
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.
wilhuff commented 6 years ago

That's a totally different problem:

Most recent error: FirebaseError: [code=failed-precondition]: The Cloud Firestore API is not available for Cloud Datastore projects.

You're trying to use the Firestore API against a project that was already enabled for Cloud Datastore.

iffj commented 6 years ago

same here. In my case it was due to the Adguard I was using

pitw commented 6 years ago

Have same Problem with Kaspersky + Firestore. @mikelehen @gamsterx Report to Kaspersky is done, hopefully they lower the restrictions. https://forum.kaspersky.com/index.php?/topic/402132-kaspersky-blocks-firestore/

mikelehen commented 6 years ago

Thanks @pitw ! Much appreciated.

steelcorsy commented 6 years ago

Have same Problem with Kaspersky + Firestore. @mikelehen @gamsterx Report to Kaspersky is done, hopefully they lower the restrictions. https://forum.kaspersky.com/index.php?/topic/402132-kaspersky-blocks-firestore/

Response of Kaspersky: According with some posts included on the link : The problem described happen

randomly and is Not only caused by kaspersky, but for other sources too..

So better contact "github.com" or Kaspersky Technical support

at this weblink : https://my.kaspersky.com/support

Then?

mikelehen commented 6 years ago

Perhaps somebody experiencing the issue can go ahead and follow the "Request Technical Support" button from https://my.kaspersky.com/support ? Be sure to let them know that at least 7 developers here are reporting that Kaspersky is preventing their Cloud Firestore apps from working and that adding https://firestore.googleapis.com/* to the trusted sites list works around the issue, but as an app developer, it's not a viable solution to ask all your customers to do that.

And if you can provide a simple site demonstrating the issue, it's probably more likely to get traction faster.

pitw commented 6 years ago

@mikelehen Its reported. We have now a trackable issue from Kasperksy. Will report here what they think.

Edit 1: They wanted some screenshots + demolinks. They got them; Now waiting how fast they are. Edit 2: "Problem +Description transmitted to Moscow, product developement "... Edit 3: Submitted 30 MB of Log files to Kaspersky as requested...waiting on final answer from product devs

Final Edit: Kaspersky opened Bug Nr. 3056440. Devs should fix this asap - then everything should work as expected.

arturcarvalho commented 6 years ago

I've been getting several exceptions caught by Sentry. I've got exceptions with Windows 10 and iOS (image below). I'm getting a lot on Windows 10.

I assume this is the same issue although I don't know how to replicate it.

Is there anything I can do to debug this further? Does reloading the page solve the problem?

Thanks.

timeoutbug

mikelehen commented 6 years ago

@arturcarvalho That error message will show up when offline or on a flaky/slow internet connection, so some percentage of your customers will hit it on a regular basis. It mostly exists to help you (the developer) during debugging.

That said, if you're getting customer reports of your app not working, that is a different matter.

arturcarvalho commented 6 years ago

Thanks @mikelehen. I'll put some kind of reload screen on the site and see how it goes.

mikelehen commented 6 years ago

I've repurposed this issue to specifically track the issues with Firestore in conjunction with Kaspersky antivirus. For folks having other issues, please open a separate issue.

For those encountering the issue with Kaspersky, I'd appreciate it if one or two of you could test out a custom build to help us better understand the problem. Unfortunately even if this build works, it would come at the expense of performance and so it's likely not something we can ship (at least on by default). To try it:

Please make sure you see a log message in the console saying "THIS IS A CUSTOM FIRESTORE BUILD FOR DEBUGGING CONNECTION ISSUES" which will confirm you're picking up the right build.

If it works as-is, let me know. Else if it does not work, can you try this (and send me the output):

const db = firebase.firestore();
db.settings({
  timestampsInSnapshots: true,
  offlineTimeout: 75  // default is 10 seconds.
});

// Also enable debug logging:
firebase.firestore.setLogLevel('debug')

If you could also save the network log (right click on a request in Chrome developer tools and choose "Save as HAR with content") that could also be useful to look at. You can email it and any logs directly to me at michael@firebase.com.

Additionally, I'm curious to confirm if Firebase Realtime Database is affected by Kaspersky or not. So could folks try visiting https://www.firebase.com/test.html and send the output (perhaps as a gist)?

Thanks!

seanw commented 5 years ago

Is there a way this error message can be promoted into a runtime exception so a warning can be shown to the user when this happens? Right now, I think a Firestore query that should always return something is returning nothing instead of the query failing. How can I differentiate between the query result being empty or this error being the problem? I'd like to show a popup to the user that the database connection is being blocked.

I'm trying to diagnose this message with a user remotely over email but will add more if I find anything interesting...

mikelehen commented 5 years ago

@seanw Unfortunately the symptom that triggers the log message (our connection to the backend not succeeding in a timely manner) is completely expected in many cases (i.e. you're intentionally offline or on a flakey network connection). So we can't make it an error.

As for behavior of our APIs though, you can essentially detect this. Just create a listener with the { includeMetadataChanges: true } option. If you get an event with snapshot.metadata.fromCache === true and don't get a subsequent event with snapshot.metadata.fromCache === false in a timely manner (use some sort of timeout), you can assume we're not able to reach the backend and you can show some sort of message to the user.

Hope this helps.

seanw commented 5 years ago

@mikelehen Thanks for the tips.

I can confirm this bug on Kaspersky Total Security 2018 by the way so looks like they're not updated their list of blocked URLs still. 😕

joshorvis commented 5 years ago

So I was having this same issue and was subscribed to this thread hoping for a solution - but then my father in law (a security guy) told me that using Kaspersky is a horrible idea. So I now suggest that the solution here is to uninstall Kaspersky wherever possible!

https://www.wired.com/story/kaspersky-russia-antivirus/

https://www.theregister.co.uk/2018/05/15/kaspersky_labs_announces_move_to_zurich_dutch_government_questions_firm/

https://www.bbc.com/news/uk-42202191

JonasJW commented 5 years ago

Yep got the same problem on a Computer with Kaspersky. Turning it off will work but I'm worried about casual users that won't know its because Kaspersky and assume the site is broken...

KristiyanFxy commented 5 years ago

It seems this is no longer a problem with one AV vendor. I am experiencing the same problem using BitDefender (total security) on Mojave 10.14.2

mikelehen commented 5 years ago

For folks running into this issue, I'd be curious if somebody could try using this custom build:

Install via npm:

npm install https://mike-shared.firebaseapp.com/webchannel-proxy-issue/firebase-v5.7.0.tgz \
  https://mike-shared.firebaseapp.com/webchannel-proxy-issue/firebase-firestore-v0.9.0.tgz \
  https://mike-shared.firebaseapp.com/webchannel-proxy-issue/firebase-webchannel-wrapper-v0.2.11.tgz

Or you can point your <script include=...> at: https://mike-shared.firebaseapp.com/webchannel-proxy-issue/firebase-firestore.js

And then initialize the SDK with a new forceLongPolling option:

  const db = firebase.firestore();
  db.settings({forceLongPolling: true});

You should see a log message saying:

WEBCHANNEL: ForceLongPolling enabled.

And then I'll be curious to know if your connection issue goes away. Please also provide as much detail as you can about your environment (browser, antivirus software / version, network details, etc.). Thanks!

pitw commented 5 years ago

In the beginning we had this issue with angular + firestore. Now switched to Vue.js but still have same error.

I still believe that Problem is on side of Kaspersky - tried many times to get some useful answer but except some "default answers" we didn't get any further.

It doesnt seem to concern all versions of Kaspersky (Endpoint Protection seems to work, Internet Security 2017 - 2019 seems to have this bug)

In case sb is interested we also opened up a thread on Kaspersky Forum here: https://forum.kaspersky.com/index.php?/topic/402132-kaspersky-blocks-firestore/ Feel free to post some experiences there ;)

frayzil commented 5 years ago

For those who are still facing this issue and want to simulate the scenario without Kaspersky Antivirus, you can easily do it with Chrome's Dev Tools. Open the Network tab and reload the page. When a connection is attempted to firestore you'll see a request made with a name starting with channel?database=.... Right click on that request and click on Block request domain.

Sadly I couldn't find a way to simulate it in other browsers. Please share if you do.

mikelehen commented 5 years ago

@sydfzlbshr I'm not sure what issue you're referring to. You are welcome to try forceLongPolling and see if it has an effect, but if you're dealing with an issue NOT related to Kaspersky, please open a new github issue. This one is specifically for Kaspersky.

Also, blocking Firestore in chrome dev tools is going to completely break Firestore and make it impossible to work. I don't think we have evidence to say that this is what Kaspersky is doing. So I don't think it's an equivalent test.

mikelehen commented 5 years ago

I have a contact within Kaspersky asking for additional tracing, screenshots, etc. to help track this down. Is there somebody that could help out? @pitw maybe? Shoot me an email at michael@firebase.com. Thanks!

gamsterx commented 5 years ago

@mikelehen What kind of screenshots do you need? I am able to reproduce the issue.

mikelehen commented 5 years ago

@gamsterx Thanks. Actually, I think I've been able to help them reproduce it so I may not need any more info for now. Will update if/when I learn more. Thanks!

frayzil commented 5 years ago

@mikelehen I tried your custom build and it works! :100: I am able to reach firestore backend even with Kasperky on.

MacOS Mojave, Safari, Kaspersky Internet Security

When will this be included in the official release? Let me know if I can help you in any other way.

mikelehen commented 5 years ago

@sydfzlbshr Thanks for the confirmation! I'm looking into adding the forceLongPolling flag to an official release, but it will probably take a bit of time. In addition, we don't intend to enable it by default because it causes additional latency and bandwidth usage, so you would need to manually opt-in to the behavior.

So I'm still hoping Kaspersky can address this on their end.

mikelehen commented 5 years ago

I've received word from Kaspersky that they have a specific plan for addressing this which should be released in the next 2-4 weeks.

Ferrasil commented 5 years ago

WEBCHANNEL: ForceLongPolling enabled.

And then I'll be curious to know if your connection issue goes away. Please also provide as much detail as you can about your environment (browser, antivirus software / version, network details, etc.). Thanks!

Hi @mikelehen , I tried to use your custom build but seems to me it doesn't work .. tried on last version google chrome . "WEBCHANNEL: ForceLongPolling enabled." in logs , but connections to firestore are in long pending status and then goes down with "Failed to get document because the client is offline." , is anything was changed in the firebase core since your custom build?

Everyday more and more new clients are coming to my application and it's getting harder to control all of them. I understand it's not your fault , I'm just mad about how long they don't want to solve this problem, sorry for the offtop

mikelehen commented 5 years ago

@Ferrasil I looked into this, and it turns out that indeed there was unfortunately a rollback on the backend that broke the forceLongPolling flag used in that test build. :-( I don't know when the behavior will be re-enabled but I'm looking into it. Sorry for the confusion.

Ferrasil commented 5 years ago

Some updates for everyone affected by this issue, I sent a detailed report to the support and finally they confirmed about the fix in the next patch release which will be in the end of March (version E) , details will appear on this page https://support.kaspersky.com/13876

pitw commented 5 years ago

@Ferrasil Thanks. Hope that they fix it finally. What did you have to do to convince them of the bug ;) ?

Ferrasil commented 5 years ago

@pitw IMHO No hopes they will fix it in that time lol :) Nothing special , I just made a tech support request and did some basic actions like they said : "download it , click record and we will collect data about your PC" => "download it, click record and repeat the bug case so we will see what happen" then they said : "This problem situation # 3056440 will be fixed in the nearest patch E for version 2019. The release of the patch according to preliminary data is scheduled for the end of March."

pitw commented 5 years ago

@Ferrasil I already was there ;)

(Watch the date - its from Oct 23 2018 !)

image

At least they give us the same bug number...