实时数据库进入只读非实时模式后性能变慢,如何恢复?
Absolutely, you can revert back to the real-time, read-write state—let’s go through some tailored steps that might resolve this even if common community fixes didn’t work for you:
Manually toggle the data viewer mode in the console
Head back to your Realtime Database console page. Look for a mode-switching button (usually labeled something like "Read-only non-realtime")—it might be at the top of the data viewer, in the right-hand menu, or behind a dropdown arrow. Click it and select the "Real-time read-write" option. Sometimes this button is easy to miss, so scan the entire console header area carefully.Clear browser cache and session data
Browser cache or stale session data can sometimes stick to the read-only mode setting. Try a hard refresh first: on Windows/Linux useCtrl+Shift+R, on Mac useCmd+Shift+R. If that doesn’t work, clear the cache specifically for the Firebase console domain: go to your browser’s privacy settings, select "Clear browsing data", and target cookies/cache for the console’s URL.Verify your database security rules
Accidentally modified security rules can lock your database into a de facto read-only state, separate from the viewer mode. Navigate to the Rules tab in your database console. Make sure your rules aren’t set to global read-only. For example, avoid rules like this:{ ".read": "false", ".write": "false" }Revert to your original rules (e.g., allowing read/write for authenticated users, or public access if that’s your intended setup).
Restart your app sessions
For mobile apps: fully close the app (don’t just minimize it to the background) and relaunch it. This forces the app to establish a fresh real-time connection to the database. For web apps: close all related tabs, then reopen both your app and the Firebase console.Check database load and performance metrics
The system might switch to read-only non-realtime mode automatically if your database is under heavy load. Go to the Monitoring tab in the console to check connection counts, read/write throughput, and latency. If load is high, consider optimizing your data structure to reduce unnecessary queries, limiting real-time listeners, or upgrading your database plan to handle more traffic.Use Firebase CLI to force mode reset
If you have the Firebase CLI installed, you can directly adjust the database mode:- Run
firebase database:settings:getto confirm the current mode. - If it’s set to non-realtime, run
firebase database:settings:set --mode=realtimeto switch back.
- Run
If none of these steps work, double-check that there are no ongoing maintenance notices for your Firebase project—rarely, platform-wide issues can trigger this behavior.
内容的提问来源于stack exchange,提问作者Muhammad Faisal

