I am building a web app (or a mobile app). Can I eliminate HTTP altogether and use WebSockets?
What are the advantages and disadvantages of this solution?
- 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.
- 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?
- Socket.io was designed to handle some shortcomings of websockets.
- Addresses Connection dropping issues with WebSockets.
- Old Browser Fallback capability.