What are WebSockets?

A brief introduction to WebSockets and their applications

Photo by Greg Rosenke on Unsplash

Background

HTTP 1.1 Request-Response Cycle
HTTP Short-Polling
HTTP Long-Polling

Okay so…what are WebSockets?

Client handshake request

GET /chat HTTP/1.1
Host: sample.com:3000
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: somekey
Sec-WebSocket-Version: someversion
HTTP 1.1 101 Switching protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: somehash
Sec-Websocket-Version: someversion
WebSocket Protocol

In what scenarios should WebSockets be used?

WebSocket Libraries

ws

Socket.io

WebSocket Solutions (SaaS)

Conclusion

References

Full Stack Web Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store