如何使用一个Node.JS服务器从许多不同的用户订阅许多NEST设备 [英] How can I subscribe to many NEST devices from many different users using a single Node.JS server

查看:101
本文介绍了如何使用一个Node.JS服务器从许多不同的用户订阅许多NEST设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为希望能够为一个或多个Node.js服务器上的许多不同用户预订许多(也许是十万个)NEST设备的客户端的项目范围.想法是聚合来自许多客户端拥有的许多设备的变更事件. Node.js可以处理那么多同时进行的Firebase更改订阅吗?最好如何管理?

I am trying to scope a project for a client that wants to be able to subscribe to many (perhaps 10's of thousands) of NEST devices for many different users from one or more Node.js servers. The idea being to aggregate change events from many devices owned by many clients. Could Node.js handle that many simultaneous Firebase change subscriptions? How would that best be managed?

谢谢

推荐答案

此处的Firebase工程师,

Firebase engineer here,

此当前方法的问题在于,Nest当前仅允许

The problem with this current approach is that Nest currently only allows a single token to authenticate at a time, and since Firebase clients cache authentication state once authenticated, in order to do this in a single process on one of said servers, you would have to auth, perform the operation, then unauth, and repeat for every operation which isn't very efficient. Listens are particularly inefficient, since this means you need to open up n socket connections, and having to switch between them in this manner somewhat defeats the purpose of using Firebase in the first place (being able to hold the connection open and get pushed updates).

您可以通过以下几种方法解决此问题:

You can solve this in a few ways:

  • Switch to multi-process and multi-server where each process has an open socket and its own auth token. Using our Node or Java client is typically the best option here.
  • Use the streaming REST API to open up multiple connections on the same server.

希望这会有所帮助!

这篇关于如何使用一个Node.JS服务器从许多不同的用户订阅许多NEST设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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