【发布时间】:2021-04-18 06:28:39
【问题描述】:
在我的主程序中,在我的 Flutter Web 应用程序开始时,我有以下代码:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseFirestore.instance.settings = Settings(
host: '127.0.0.1:8080',
sslEnabled: false,
);
然而,当我尝试获取文档时,出现以下错误:
客户端离线,获取文档失败
我的 firebase.json 如下:
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"emulators": {
"firestore": {
"port": 8080
},
"hosting": {
"port": 5000
},
"ui": {
"enabled": true
}
}
}
【问题讨论】:
-
试试
localhost:8080而不是127.0.0.1:8080 -
它不适用于 localhost:8080
-
在发布此问题之前,我确实尝试过关注此问题。我仍然收到错误:
Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds。然后程序继续到[WatchStream]: (3d19be0) Stream closed with status: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null}.。然后查询在线FireStore。
标签: firebase flutter google-cloud-firestore