2

I'm trying to find the IP address of a client when they make a particular LCDS service call. Understanding all the issues of getting a "real" IP address and privacy concerns and so on, it is possible to find the client's IP address?

tj

Travis Jensen
  • 5,362
  • 3
  • 36
  • 40

3 Answers3

1

I think you can get hold of it pretty easily. Not tested, but give it a try.

String ip = FlexContext.getHttpRequest().getRemoteAddr();
Gregor Kiddie
  • 3,119
  • 1
  • 19
  • 16
  • I think that will work for certain kinds of channels, but it doesn't appear to work for RTMP channels. The HTTP request object is null. – Travis Jensen Aug 31 '09 at 19:17
1

I didn't find a way how to do it for all channel types with a simple method call. So I use such code:

    String ip;
    Endpoint clientEndpoint = FlexContext.getEndpoint();
    if (clientEndpoint instanceof RTMPEndpoint) {
       ip = ((RTMPFlexSession)FlexContext.getFlexSession()).getClientInfo().getIp();  
    }
    if ((clientEndpoint instanceof NIOAMFEndpoint) || (clientEndpoint instanceof AMFEndpoint)) {
       ip = FlexContext.getHttpRequest().getRemoteAddr();
    }
Roman
  • 31
  • 2
0

ip = FlexContext.getHttpRequest().getRemoteAddr();

is gives whoz connected

Thanks Roman