Skip to content

Lunuy/fetch-upload-streaming-chat-sibal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fetch Upload Streaming HTTP/2 Chat (Using Sibal Protocol)

Chat example using HTTP/2 Streaming request and Streaming response.

Server

cd server
npm i -D
npm run watch

Server will serve on https://127.0.0.1:8000, using celf-certificated certs.

Web Client

cd client
npm i -D
npm run serve

http://127.0.0.1:9000

You may need to use chrome canary(> 105). You should go to https://127.0.0.1:8000/ once, and select continue (to ignore security error of self-certificated certificate).

How it works

Because browser does not support full-duplex http/2 connection yet, we use two http connections for download and upload.

  1. Client establishes download stream connection(GET)
  2. Server generates temporary id for the client and sends it to the client.
  3. Client establishes upload stream connection(POST) and sends temporary id that received from server.
  4. Now server knows upload and download stream connection pair for the client.
  5. Full-duplex connection is established using two stream connections(download, upload).

Why use Sibal Protocol?

Upload and download stream is like tcp socket, fetch upload stream does not guarantee each chunk to be sent separately, of course download stream does not guarantee those thing too. So we need messaging protocol to seperate each message. Sibal is simple protocol to separate each message. It is implemented with Web Streams API, which you can use in both browser and node environment so that you can use it easily.

About

Fetch upload streaming chat example using Sibal protocol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published