WebSocket vs HTTP
Yesterday I learned more about the WebSocket communication protocol. Compared to HTTP(s), WebSocket allows:
- Server to communicate with client without client first sending a request.
- Multiple messages going back and forth between client and server in a single connection.
WebSocket is thus a better fit for applications that need up-to-date ongoing data communication, for example:
- Messaging
- Gaming
- Trading
On the other hand, WebSocket lacks the HTTP verbs and status codes, thus HTTP(s) is still king for building RESTful APIs.