Network Bi-directional Protocols
Websocket
- a protocol that operates over a TCP connection
- bi-directional communication protocol
- it’s stateful because it involves establishing a long-lived TCP connection
- support binary data like images, audio, video, or any raw binary content
- it’s stateful
Server-Sent Events (SSE)
- SSE uses HTTP/1
- unidirectional communication protocol from server to client
- it allows a web server to push updates to a client
- is text-based and doesn’t support binary data
- over http/2
- It’s binary, instead of textual, making it more efficient to parse
- It’s still unidirectional updates (server to client)
- over http/3
- chatGPT uses this protocol over http/3
text/event-stream; charset=utf-8
WebRTC (Web Real-Time Communication)
- real-time communication directly between browsers or apps
- used for video and audio chat, but it can also be used for text chat
- Large data transfer
- Direct use on browser
MQTT (Message Queuing Telemetry Transport)
check here
gRPC
- use HTTP/2 for transport, which allows for client-server and duplex streaming of data
- Suitable for large data transfer and small API calls
How to expose gRPC like RESTful does for support gRPC?
you might need gRPC Gateway that translate a JSON API into gRPC payload
Does browser, which supports HTTP 2, support gRPC?
No, either use “gRPC-Web” or “gRPC Gateway”
gRPC-Web is designed to be used in the browser. It’s implemented as a JavaScript library and also requires a proxy layer (like Envoy) in your backend to translate between gRPC-Web requests and gRPC.
XMPP (Extensible Messaging and Presence Protocol)
- it’s based on XML
- not popular as others
ref: