[websocket][tomcat] org.atmosphere.cpr.AtmosphereRequest.getRemoteAddr() returns empty string
org.atmosphere.cpr.AtmosphereRequest.getRemoteAddr() returns empty string instead of correct address.
atmosphere-runtime 1.0.4
@hapali Which server? I suspect you are using Tomcat behind Apache, and that's a known issue (see Tomcat site)
no apache, just tomcat 7.0.33 with blocking io connector
Using WebSocket?
yes, websockets
apache-tomcat-8.0.21 & atmosphere-websockethandler-pubsub-2.3.0
@WebSocketHandlerService (path ="/pubsub", broadcaster = SimpleBroadcaster.class)
public class WebSocketPubSub extends WebSocketHandlerAdapter {
public void onOpen(WebSocket webSocket) throws IOException {
System.out.println(webSocket.resource().getRequest().getRemoteAddr());
}
}
getRemoteAddr() return "0.0.0.0", cannot get the correct ip...
Tomcat doesn't expose those values, here it won't work with Tomcat. Works with Jetty.
Hi Jeanfrancois!
We ran into the same problem but we can't switch to Jetty or something else. We need to log the ip addresses, so what is the best way to do it? All @ Ready events need to be logged and we use a @ ManagedService.
tomcat version: 8.0.23 atmosphere version: 2.3.0
@d03090 You will need to write a Tomcat's valve, log the ip from there and retrieve it as a request's attributes in Atmosphere. That's the kind of work Async-IO is doing...it will requires a couples of hours of work to 'fix' Tomcat. The alternative is you file a bug in Tomcat so they fix it, event if the spec is unclear about it. Butthe Valve approach is the easiest and fastest IMO.
@jfarcand I have the same problem with Atmosphere 2.4.2 and Tomcat 8.0.22. When I do:
resource.getRequest().getRemoteAddr()
I always get an empty address.