apache tomcat 8 websocket origin and client address
Posted
by
user2926082
on Stack Overflow
See other posts from Stack Overflow
or by user2926082
Published on 2013-10-27T21:51:00Z
Indexed on
2013/10/27
21:53 UTC
Read the original article
Hit count: 227
i hope someone can help me ... i am using apache tomcat 8.0.0-RC5 and JSR-356 web socket API ... I have 2 questions:
1) Is it possible to get the client ip on @OnOpen method ??
2) Is it possible to get the origin of the connection ???
I followed the websocket example which comes with the distribution of tomcat and i was not able to find the answers .... My java class is basically as follow
@ServerEndpoint(value = "/data.socket")
public class MyWebSocket {
@OnOpen
public void onOpen(Session session) {
// Here is where i need the origin and remote client address
}
@OnClose
public void onClose() {
// disconnection handling
}
@OnMessage
public void onMessage(String message) {
// message handling
}
@OnError
public void onError(Session session, Throwable throwable) {
// Error handling
}
}
© Stack Overflow or respective owner