WebSocket + Node.js + Express â Step by step tutorial using Typescript
Update
Checkout my new Angular WebSocket client article ð.
You could be interested in my article about realtime and schemaless database (Cloud Firestore) and Angular -> Step by step tutorial and âCUD operations, transactions and batch writes deep diveâ.
This is a quick step by step tutorial about WebSocket, Node/Express and Typescript. The full source code provided in these examples is lovely hosted by Github.
WebSocket is a communication protocol that provides a full-duplex communication channels over a single TCP connection established between a web browser (client) and a web server (this take place through the âclassic HTTP mechanismâ of handshaking, implemented using request/response headers).
This allows the server to send content to the browser without being called by the client, pushing data through the opened connection, defining ws
and wss
as URI schemes used respectively for unencrypted and encrypted connections.
In this tutorial we are going to use ws, a simple client/server library for Node.js that helps us to manage all the stuff under the protocol.
I choose this library instead of the well known Socket.IO because today the WebSocket protocol is nativelyâ¦