We are happy to share with you our WebSockets proof-of-concept, which demonstrates the potential of enabling WebSockets on the IC through a dedicated gateway.
To facilitate WebSocket connections between frontends and canisters on the IC, we use a gateway. This gateway provides a standard WebSocket endpoint for frontends and handles the communication with the canister. It establishes WebSocket connections with canisters through update calls and uses polling to obtain the latest messages and deliver them to the client.
We invite you to explore the code on GitHub, available at GitHub - dfinity/ic-websocket-poc. This repository can serve as a starting point for developers interested in leveraging WebSockets on the IC. However, please note that this proof-of-concept requires further improvements to enhance security and stability (e.g. using SSL and enhancing error handling) and is not usable in production.
We encourage you to give it a try and let us know what you think!
Amazing, Dfinity opening up its wide harms.
Hey! that’s an amazing feature. Let people to create DApps where communication is not a problem. Congrats to Dfinity team!
Regarding security, what is the vision there? E.g. will the websockets support certified data, equivalent to certified queries? I.e. will a developer be able to take data, sign it as for certified queries, then post it and have it validated by the service worker? The crypto part is definitely possible to do oneself; does it make sense to include such functionality out of the box to make it easy for developers to write secure code first time?
The proof-of-concept already makes use of certification and signatures so that the gateway is trustless. Messages from the canister (together with a timestamp and a sequence number) are certified. Likewise messages from the client are signed using the key the client registered in the first update call.
Me and @ilbert are planning to continue the work on this PoC. If interested in more details check this out.