June 2021
Intermediate to advanced
398 pages
9h 35m
English
In the last chapter, we talked about communicating with the server using regular HTTP requests and receiving either HTML or JSON in response. One feature of our server interactions in both Stimulus and React is that we are simulating a real-time connection with the server by polling the server repeatedly. Polling this way has a couple of potential drawbacks. There’s some extra overhead to make all the HTTP calls locally, and pestering the server often can have bad performance implications.
An alternative for client-server communications is to use the WebSocket protocol. The WebSocket protocol allows a client and a server to communicate over a single long-lived connection. A common analogy ...
Read now
Unlock full access