• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java WebSocket server with embedded container

 
Tim Cooke
Sheriff
Posts: 3295
153
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Morning fellow Ranchers,

In a few days I'm going to be building a really small Java application that has to accept WebSocket requests and do some really simple things with it. To give you an idea of scope, I'm expecting that no more than ~30 lines of code will be required for the whole thing.

Ideally I'd like to build this app as a completely self contained unit that can be run up on a specified port (there may end up being a few different flavours of these applications to be run next to each other). As part of that dream I'd like to embed a web container in the package so a separate installation of Tomcat, Jetty, or whatever is not required. I've done a bit of searching and found that both Tomcat and Jetty have options to be embedded but having never done this before I'm looking for some advice on what's the easiest and/or best way to do this.

Any advice?
 
Tim Cooke
Sheriff
Posts: 3295
153
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ended up using the Jetty embedded WebSocket server along with the javax.websocket library.

Turns out it was really easy by following the example here -> https://github.com/jetty-project/embedded-jetty-websocket-examples/tree/master/javax.websocket-example
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!