Ad

Is It A Good Idea To Run Socket.io On A Firebase Cloud Function?

Implementing it works, but I have read that due to how Cloud Functions are designed they are not the best way to use socket.io. Why?

Ad

Answer

Actually, socket.io does not work with Cloud Functions. Cloud Functions have the following properties that make them incompatible with long-lived socket connections:

  1. The maximum duration of a Cloud Function can only be 9 minutes. The socket will be forced closed after that time. This is counter to the normal expectation of socket.io to keep a socket connection alive indefinitely.
  2. Cloud Functions will read the entire contents of the request, and only then will write the entire contents of the response. There is only one full round trip - a client can not "chat back and forth" over the connection with the function.

See also

Ad
source: stackoverflow.com
Ad