[英]Can I use a WebSocket protocol to send and receive data from Cloud Firestore using an ESP32S3 Using ESP-IDF C
Google is deprecating Cloud Iot, so not an option.谷歌正在弃用 Cloud Iot,所以不是一个选择。 https://cloud.google.com/iot/docs/release-notes
https://cloud.google.com/iot/docs/release-notes
Cloud IoT Core will be retired on August 16, 2023. After August 15, 2023, the >documentation for IoT Core will no longer be available.
Cloud IoT Core 将于 2023 年 8 月 16 日停用。2023 年 8 月 15 日之后,>IoT Core 的文档将不再可用。
I would like to use Firebase - Firestore for my backend.我想使用 Firebase - Firestore 作为我的后端。 It takes all the hassles out of keeping a server up and running, scalability etc.
它消除了保持服务器正常运行、可扩展性等方面的所有麻烦。
I managed to send data after login and authentication from an ESP32S3 using ESP-IDF in C, (note not Arduino, and not C++), and would like to know if I can rather use a websocket for the communication, once the Authentication done, and if so, can you give me a code example or pointers.我在 C 中使用 ESP-IDF 从 ESP32S3 登录和验证后成功发送数据(注意不是 Arduino,也不是 C++),并且想知道我是否可以使用 websocket 进行通信,一旦验证完成,如果是这样,你能给我一个代码示例或指示吗?
With a websocket, I can send data to my own server hosted in Europe, in less than 400ms.使用 websocket,我可以在不到 400 毫秒的时间内将数据发送到我自己在欧洲托管的服务器。 With Firestore, there is a large HTTP header, that includes the API key, and also the Auth Token, a large amount of data, quite a lot of handshaking going on over HTTPS, and eventually the data is sent.
使用 Firestore,有一个很大的 HTTP header,其中包括 API 密钥,还有 Auth Token,大量数据,在 HTTPS 上进行了大量的握手,最终发送了数据。 This takes more than 1400ms.
这需要超过 1400 毫秒。
We are weighing items in a farming scenario, and need to weigh very frequently, and the 1400ms with fast inte.net is not acceptable.我们在农耕场景中称重物品,需要非常频繁地称重,1400ms 的网速快是不行的。 So if I could still go with Firebase Authentication, and Firestore for data, I probably would be able to speed it up to even faster than 400ms if I could use a WebSocket client connection with the Firestore document store.
因此,如果我仍然可以使用 go 和 Firebase 身份验证,以及用于数据的 Firestore,如果我可以使用 WebSocket 客户端连接与 Firestore 文档存储,我可能可以将它的速度提高到甚至超过 400 毫秒。 I can use the Refresh Token if needed to refresh the Auth Token, and thus keep the socket connection up, every 3600s as required by Firebase, (that also takes quite long) but less of a hassle, as only once every say 55 minutes.
如果需要刷新 Auth Token,我可以使用 Refresh Token,从而保持套接字连接,按照 Firebase 的要求每 3600 秒(这也需要相当长的时间)但麻烦更少,因为每 55 分钟一次。 Any pointers, advice will be appreciated.
任何指针,建议将不胜感激。
Firestore supports multiple SDKs and wire protocols, but none of them work over web sockets. The closest you can get with Firestore would be its REST API, which is documented here . Firestore 支持多种 SDK 和有线协议,但它们都不支持 web sockets。Firestore 最接近的是它的 REST API,记录在此处。 It's not the easiest protocol to work with though, so I recommend using the API explorer that is built into the documentation to create examples for yourself.
虽然它不是最容易使用的协议,因此我建议使用文档中内置的 API 资源管理器来为自己创建示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.