如何使用 charles 代理检查 Firestore 网络流量?

How to inspect Firestore network traffic with charles proxy?

据我所知,Firestore 在从 android/ios 应用建立连接时使用协议缓冲区。出于好奇,我想看看什么网络流量在上升和下降,但我似乎无法让 charles proxy 显示任何真实的解码信息。我可以看到打开的连接,但我想看看线路上发生了什么。

Firestores sdks 似乎是开源的。所以应该可以用它来帮助解码输出。 https://github.com/firebase/firebase-js-sdk/tree/master/packages/firestore/src/protos

一些 Google 服务(例如 AdMob:https://developers.google.com/admob/android/charles) have documentation on how to read network traffic with Charles Proxy but I think your question is, if it’s possible with Cloud Firestore since Charles has support for protobufs

答案是:现在不可能。可以看到 firestore 请求,但实际上无法读取任何正在发送的数据,因为它使用的是协议缓冲区。没有关于如何将 Charles 与 Firestore 请求一起使用的文档,产品团队对此有一个未解决的问题(功能请求),没有 ETA。同时,您可以尝试 Protocol Buffers Viewer.

查看 Firestore 网络流量的替代方案可以是:

来自 Firestore documentation

For all app types, Performance Monitoring automatically collects a trace for each network request issued by your app, called an HTTP/S network request trace. These traces collect metrics for the time between when your app issues a request to a service endpoint and when the response from that endpoint is complete. For any endpoint to which your app makes a request, Performance Monitoring captures several metrics:

  • Response time — Time between when the request is made and when the response is fully received
  • Response payload size — Byte size of the network payload downloaded by the app
  • Request payload size — Byte size of the network payload uploaded by the app
  • Success rate — Percentage of successful responses compared to total responses (to measure network or server failures)

You can view data from these traces in the Network requests subtab of the traces table, which is at the bottom of the Performance dashboard (learn more about using the console later on this page).This out-of-the-box monitoring includes most network requests for your app. However, some requests might not be reported or you might use a different library to make network requests. In these cases, you can use the Performance Monitoring API to manually instrument custom network request traces. Firebase displays URL patterns and their aggregated data in the Network tab in the Performance dashboard of the Firebase console.

来自 ,

The wire protocol for Cloud Firestore is based on gRPC, which is indeed a lot harder to troubleshoot than the websockets that the Realtime Database uses. One way is to enable debug logging with:

firebase.firestore.setLogLevel('debug');

完成后,调试输出将开始记录。