Skip to content

thegeekyasian/WebSocket-SpringBoot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebSocket-SpringBoot | Getting Started

Requirements

For building and running the application you need:

Build Application

You can build the application by using the maven build command like so:

mvn clean install -DskipTests

Connecting to the WebSocket/ServerEndpoint

  • 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.

Broadcasting Messages to WebSocket 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 or POST call on http://localhost:8080/broadcast?message=Hello World, and your socket listeners will receive the message Hello World on their clients.

WebSocket Simple Client

You can also use this WebSocket Client. Download the WebSocket-Client.zip from HERE.

The Tutorial

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

About

A project on how to use ServerEndpoint in Web Socket for Spring Boot, with embedded server. It took me a while to figure out the problem that was solved by exporting the server endpoint.

Topics

Resources

Stars

Watchers

Forks

Languages