带有socket.io的Google Cloud Functions [英] Google Cloud Functions with socket.io
问题描述
我的理解是,要使用socket.io建立持久的套接字连接,Node.js服务器应始终处于运行状态.有了Google Cloud Functions,并不总是运行Node.js服务器,因此无法保持套接字连接处于活动状态.
My understanding is that to establish a persistent socket connection using socket.io the Node.js server should be always running. With Google Cloud Functions there isn't an always running Node.js server, so keeping a socket connection alive is not possible.
使用运行中的Node.js服务器运行Cloud是使用socket.io处理多个套接字连接的最佳选择吗?
Is Cloud Run with a running Node.js server the best option to handle multiple socket connections using socket.io ?
推荐答案
出于相同的原因,Cloud Functions和Cloud Run均不能支持持久套接字连接.每个请求都有一个不能为无限的超时.如果要有效地使用socket.io,则需要一个不同的后端-可以完全控制服务器实例的后端.
Neither Cloud Functions nor Cloud Run are able to support persistent socket connections for the same reasons. Each request has a timeout that can't be infinite. If you want to use socket.io effectively, you will need a different backend - one where you fully control the server instances.
这篇关于带有socket.io的Google Cloud Functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!