Real-Time Communication: Implementing Websockets With Spring Boot

Thomas Kendall Development Technologies, Java, JavaScript, Spring Boot 3 Comments

When developing web applications, we sometimes need to push server events down to connected clients. However, HTTP was not designed to allow this. To get around this limitation, a polling pattern was established where web pages would intermittently poll the server for any new events. This pattern was not ideal as it added HTTP overhead, was only as fast as the polling rate, and caused unnecessary load on the server.

Luckily, with the emergence of HTML5 came the WebSocket. The WebSocket protocol enables interaction between a browser and a web server with lower overheads. In this blog we’ll introduce the Websockets API and show how to implement Websockets with Spring Boot.