Firebase 实时数据库连接终止:不同地区 [英] Firebase Realtime Database connection killed: Different Region

查看:27
本文介绍了Firebase 实时数据库连接终止:不同地区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个使用 Firebases 实时数据库的简单登录用户身份验证 Android 应用程序,但出现错误:

I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:

[Firebase 数据库连接被服务器强行终止.不会尝试重新连接.原因:数据库位于不同的区域.请将您的数据库 URL 更改为 https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]

[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]

由于我住在菲律宾,我目前正在使用新加坡(asia-southeast1)服务器.这是错误的吗?还是我应该使用美国的?如何更改我的数据库 URL?

I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?

推荐答案

您使用的 google-services.json 文件似乎不包含实时数据库 URL,可能是因为您下载了它在创建数据库之前.在这种情况下,SDK 假定数据库位于美国(原始区域),并且您会收到一个错误,指出存在不匹配.

It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.

有两种可能的解决方案:

There are two possible solutions:

  1. 从 Firebase 控制台下载更新的 google-services.json,并将其添加到您的 Android 应用中.
  2. 在您的代码中指定数据库 URL,如下所示:FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...
  1. Download an updated google-services.json from the Firebase console, and add that to your Android app.
  2. Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...

两者都有相同的结果,因此请选择您认为最简单的那个.

Both have the same result, so pick whichever one seems easiest to you.

这篇关于Firebase 实时数据库连接终止:不同地区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆