For building and running the application you need:
You can build the application by using the maven build command like so:
mvn clean install -DskipTests
-
After cloning the repo on your local machine, start the SpringBoot application.
-
The application will be started on
http://localhost:8080/
. You can configure and start the application on a different post. -
The application will expose two endpoints.
i. WebSocket (ws) Endpoint
ii. HTTP Endpoint
-
You need to establish a WS connection on
ws://localhost:8080/webSocket
with your websocket client. -
Once you establish a connection to the WebSocket endpoint, you will start listening to any messages that get broadcasted to the listeners.
- To broadcast the message, you need to use the
http://localhost:8080/broadcast
endpoint. - A query parameter
message
has been set up to broadcast messages. - Make a HTTP
GET
orPOST
call onhttp://localhost:8080/broadcast?message=Hello World
, and your socket listeners will receive the messageHello World
on their clients.
You can also use this WebSocket Client. Download the WebSocket-Client.zip
from HERE.
If you want to learn how to create WebSocket in Spring Boot with the better understanding, you can check out a step-by-step tutorial on my blog HERE