Chapter 12. WebSocket
This chapter covers
- The concept of a real-time web
- The WebSocket protocol
- Building a WebSocket-based chat room server with Netty
If you follow recent developments in web technologies you are likely to come across the phrase real-time web, and if you have had experience with real-time applications in engineering domains, you may be a little skeptical about what this term implies.
So let’s clarify at the outset that this is not about so-called hard real-time Quality of Service (QoS), where the delivery of computation results within a specified time interval is guaranteed. The request/response design of HTTP alone makes that highly problematic, as evidenced by the fact that none of the approaches devised in the past have provided a satisfactory solution.
And while there has been some academic discussion about formally defining the semantics of timed web services,[1] universally accepted definitions don’t appear to be on the horizon. So for now we’ll accept the following non-authoritative description from Wikipedia as adequate:
1“Real-time Web Services Orchestration and Choreography,” http://ceur-ws.org/Vol-601/EOMAS10_paper13.pdf.
The real-time web is a network web using technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates.