websockets versus HTTP Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/tag/websockets-versus-http/ Production Grade Technical Solutions | Data Encryption and Public Cloud Expert Fri, 17 Nov 2017 17:27:47 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.2 https://www.anujvarma.com/wp-content/uploads/anujtech.png websockets versus HTTP Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/tag/websockets-versus-http/ 32 32 WebSockets–versus HTTP https://www.anujvarma.com/websockets-versus-http/ https://www.anujvarma.com/websockets-versus-http/#respond Fri, 17 Nov 2017 17:26:00 +0000 http://www.anujvarma.com/?p=5032 I am building a web app (or a mobile app). Can I eliminate HTTP altogether and use WebSockets? Not completely. To  perform a websocket handshake , one needs HTTP. Once […]

The post WebSockets–versus HTTP appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
I am building a web app (or a mobile app). Can I eliminate HTTP altogether and use WebSockets?

Not completely. To  perform a websocket handshake , one needs HTTP. Once the handshake is successful, you can switch to websockets entirely. If your app runs in a browser, you may also need to serve a HTML/JavaScript file(s) for the landing page, which will require HTTP.

What are the advantages and disadvantages of this solution?

Advantages

  • Full Duplex, stateful communication (unlike HTTP).
  • Real server push (you can easily notify clients) .
  • Add a layer on top of WebSockets (e.g. json rpc), and you can outperform HTTP.

Disadvantages

  • Bare bones TCP, so your  app may require another protocol on top of that. Which could affect performance and reliability. Especially if you want to mix textual content (e.g. json) with binary content (e.g. images). You may end up reinventing the HTTP protocol over websockets.
  • Not as many tools as for HTTP

What about Socket.io?

  1. Socket.io was designed to handle some shortcomings of websockets.
  2. Addresses Connection dropping issues with WebSockets.
  3. Old Browser Fallback capability.

The post WebSockets–versus HTTP appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
https://www.anujvarma.com/websockets-versus-http/feed/ 0