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?
You should use Cloud Functions for Firebase if you're a developer building a mobile app or mobile web app. Firebase gives mobile developers access to a complete range of fully managed mobile-centric services including analytics, authentication and Realtime Database.
"Realtime backend made easy", "Fast and responsive" and "Easy setup" are the key factors why developers consider Firebase; whereas "Real-time", "Event-based communication" and "Node. js" are the primary reasons why Socket.IO is favored.
All of your data syncs automatically through the single WebSocket as fast as your client's network can carry it and Firebase sends you new data as and when it's updated. When your client saves a change to the data, all clients who are connected, receive the updated data almost instantly.
Conclusion. I think Socket.io is a very useful piece of technology and is incredibly relevant today in spite of the popular view that widespread support for WebSockets makes it redundant. I would recommend that it be used for highly interactive applications. Its namespacing in particular is its strongest point.
Actually, socket.io does not work with Cloud Functions. Cloud Functions have the following properties that make them incompatible with long-lived socket connections:
See also
Cloud Functions are made for simple requests, they are not made for long-running processes. If you want to stick with serverless architecture, try Cloud Run. They released an update this year (January 2021) and the platform is now able to support WebSockets including Socket.io.
Here is the link to the Cloud Run documentation
Here is the link to the blog post (their announcement)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With