I'm learning websockets. What I have done is established a websocket connection with Tomcat as server endpoint and for client side I have used JavaScript. Everything is fine.
What I want to know is if it is possible to have another Tomcat container as client endpoint? If so how can it be established? Or is it possible to use servlet or REST endpoint as client endpoint like:
@webservlet("/sampleservlet")
@clientendpoint
or
@requestmapping("/hello")
@clientend
A websocket could be programmatically established between one webserver and another. There are two scenarios that I can think of for your "server liveness" problem.
The monitoring webserver could have a background thread (i.e. not associated with any client request) that uses (say) the Apache HTTPComponents libraries to establish a websocket connection to the monitored service.
The monitoring webserver could actually tunnel a connection from the user's browser to the monitored service.
I don't think these are particularly good ideas (especially the second one). A better idea would be to use ordinary requests to do the liveness monitoring. (If you use websockets, there is a risk that your monitoring will mislead; e.g. if the monitored service stops accepting new requests.)
Another idea would be to use JMX, or plain sockets to implement the monitoring.