在Cloud Functions for Firebase上运行Web套接字? [英] Run a web socket on Cloud Functions for Firebase?

查看:46
本文介绍了在Cloud Functions for Firebase上运行Web套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我实际上有一个使用REST请求在Cloud Functions for Firebase上运行的REST api,但是现在我需要实时将数据同步到这些函数.我读了一些有关Web套接字的信息.

Hello I actually have a REST api running on Cloud Functions for Firebase using http request, but now I need to sync the data on real time requesting to the functions. I read something about web sockets.

是否可以在Cloud Functions for Firebase上运行Web套接字?

Is there a way to run a web socket on Cloud Functions for Firebase?

推荐答案

这不适用于Cloud Functions. Websocket依赖于长期以来与同一服务器的长期连接;云功能是短暂的计算实例,在没有流量时会被分解.无法强制或保证Cloud Function将无限期保持运行或保持连接打开.

This is not going to be a good fit for Cloud Functions. Websockets rely on long-lived connections to the same server over time; Cloud Functions are ephemeral compute instances that are spun down when there's no traffic. There's no way to force or guarantee that a Cloud Function will keep running or hold a connection open indefinitely.

我鼓励您在此处研究使用Firebase实时数据库作为管道,而不是尝试向Cloud Functions添加实时.

I would encourage you to investigate using the Firebase Realtime Database as a conduit here instead of trying to add realtime to Cloud Functions.

这篇关于在Cloud Functions for Firebase上运行Web套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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