Skip to content

Commit

Permalink
Update websockets-poc.md
Browse files Browse the repository at this point in the history
  • Loading branch information
harpa12 authored Jul 5, 2023
1 parent 37d8e70 commit 189796f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions blog/features/websockets-poc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "A step towards WebSockets on the Internet Computer"
description: Introducing a WebSocket proof-of-concept for the community to build on.
description: Introducing a WebSocket proof-of-concept for the dev community to build on.
tags: [Devs]
image: /img/blog/motoko-sentinel.png
---
Expand All @@ -9,32 +9,32 @@ Today, users expect web applications to be fast and snappy: an exchange should u
the prices in real-time, edits of colleagues should appear immediately when collaborating
on a document, and comments on social media platforms should update continuously.

To provide such a user-experience, modern web applications usually rely on WebSockets,
which allow to establish a long-lived, full-duplex connection between the frontend
and backend of an application. This allows for both sides to send data, for example
To provide such a user-experience, modern web2 applications usually rely on WebSockets,
which allow establishing a long-lived, full-duplex connection between the frontend
and backend of an application. This allows for both sides to send data, for example,
the latest exchange rates, in real-time.

## Challenges

While WebSockets are a standard in the web2 world, they have unfortunately not yet
found their way to web3. We aim to change that and bring WebSockets to the Internet Computer.
While WebSockets are a standard in the web2 world, they have not yet
found their way to web3. We aim to change this for the Internet Computer blockchain.

Unfortunately, this is not a straightforward undertaking due to the decentralized
nature of the Internet Computer, where the backend does not just run on a single
centralized entity, but on multiple replica nodes in a subnet. To enable WebSockets
on the Internet Computer, we need to address the following two main challenges:

_One-to-one connections_ - WebSockets are one-to-one connections: the frontend establishes
a connection with a single centralized backend. An application on the Internet Computer
however is running distributed across multiple replica nodes in a subnet. In order
a connection with a single centralized backend. An application on the Internet Computer,
however, is running distributed across multiple replica nodes in a subnet. In order
to enable WebSockets, there needs to be a point of consolidation, which provides a
single contact point for the frontend.

_Long-lived connections_ - WebSockets remain open for long periods of time. The
canisters on the Internet Computer however follow the actor model, which accepts
a message, processes it and replies.

To get started and gain experience, we decided to take one step at a time and first
To get started and gain experience, we decided to take things one step at a time, and first
build a proof-of-concept instead of trying to directly integrate WebSockets fully
into the Internet Computer.

Expand All @@ -53,7 +53,7 @@ The gateway sends messages coming from the frontend as update calls to the backe
and it continuously polls the backend for new messages for the frontend.

Despite being a centralized point of failure, the gateway draws on the Internet Computer
to fulfill its role trustlessly: both the frontend and the backend sign their messages
to fulfill its role trustlessly: both the frontend and the backend sign their messages
such that the gateway cannot tamper with them.

## Try it out!
Expand Down

0 comments on commit 189796f

Please sign in to comment.