Using Java Websocket API Implementation without a

2019-07-13 20:15发布

Is it possible to implement a custom WebSocket app in Java without having to run it on a Web-Server like GlassFish, Tomcat, Jetty etc?

I intend to develop a very custom-tailored App and would like to implement my own way to manage threads, monitoring, load balance, messaging and stuff like that. (compared with e.g. Java TCP’s ServerSocket ) I know there are Tyrus containers such as Grizzly integration for standalone server and Servlet support and here is Jetty as well, but I am not sure if that is what I am looking for. Is Grizzly or Jetty perhaps a standalone solution per se? I know Tyrus is some kind of wrapper for Grizzly WebSocket Implementation but to be honest, I am not sure how those two are interconnected.

Any suggestions are more than welcome! Thank you!

2条回答
可以哭但决不认输i
2楼-- · 2019-07-13 20:48

Tyrus is not "some kind of wrapper of Grizzly", but it can run on top of it.

(Tyrus is Reference implementation for WebSocket API for Java (JSR 356), which is part of Java EE).

Running without web server (assuming you are talking about appserver or something "big") is perfectly possible and very simple, since we are using this for our "e2e" testing. (I'm Tyrus developer if that matters).

Starting new container which can process WebSocket connections is as simple as: Main.java , see project declaration [pom.xml] for complete list of dependencies.

查看更多
唯我独甜
3楼-- · 2019-07-13 20:57

In other words, you're trying to implement a WebSocket server, something like: https://code.google.com/p/jwebsocket/ (link is dead)

http://jwebsocket.org/downloads/jwebsocket-latest-versions (new link)

查看更多
登录 后发表回答