ZdeenaP ZdeenaP - 4 years ago 233
Java Question

Websocket getting remote IP on connect

Can I get remote IP address inside

@OnOpen
method of
@ServletEndpoint
class?
I tried follow this Accessing HttpSession from HttpServletRequest in a Web Socket @SocketEndpoint but as in Websocket - httpSession returns null it doesn't work.

Anyway I only need clients IP address.

Answer Source

The JSR-356 Websocket specification does not expose client IP address.

You may try one of the 2 hacks descibed in this response: JSR-356 WebSockets with Tomcat - How to limit connections within single IP address?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download