Spring-Boot / Websocket Example

It’s been a while!

Project for this post: https://github.com/mtrojahn/spring-boot-websocket

Recently I stumbled upon the need of using Websockets. I confess I know little about the subject and I hope this little tutorial can help you to get started. I’m making this post just because I tried to help here on StackOverflow and I thought I should just post it here as well.


Application.class (nothing special here)



This is the main thing. For this example I added a scheduled method that will periodically broadcast a message to all clients and another method that will just respond if a client send a “/ping” command.

Now, for the client I have this simple script:


See you next time (and I hope I have more time to explain things).

You may also like...

2 Responses

  1. Lucas says:

    you could at least finish the example

    • Thanks for your reply but I’m not sure what you mean. The example is fully functional. The button “Send Ping” sends the websocket command to the server and the result is logged on the console. You can download the full project from the Github repository listed on the post.

Leave a Reply

%d bloggers like this: