Skip to main content
16-Pearl
January 23, 2018
Solved

Does Resources["CurrentSessionInfo"].GetCurrentIPAddress() return the IP address, received by Tomcat server but not Client IP ??

  • January 23, 2018
  • 2 replies
  • 3189 views

I tested below API by testing a Thing service.

     Resources["CurrentSessionInfo"].GetCurrentIPAddress().


With below testing results, I assume this API returns IP received by Tomcat server?

I also tried tracking source code however have not found when and what kind of IP was set. Anyone could know the exact answer??

  • when using proxy server, proxy server IP was displayed.
  • when no proxy server, IE client IP was displayed.
Best answer by wcui

Hi Sushant, thanks for your comment. Actually this issue has been resolved with below results. Please take a ref.

1. By checking the coding, I found function <GetCurrentIPAddress> works as below.

  • Firstly it tries to return the value of XFF(x-forwarded-for) field from HTTP header.
  • If header does not contain XFF field, the IP, which web server(Tomcat) finally receives, will be returned.

2. I tested with Squid proxy server in 2 converse patterns.

    This proxy production can adds or does not add XFF filed into HTTP header according to your configuration.

  • When adding XFF, function returned client IP.
  • When no XFF, function returned proxy server IP.

Below is Wikipedia explanation for XFF usage with Proxy server/Load Balancers, just FYI.

2 replies

5-Regular Member
January 26, 2018

Hi Wenjing, i just tested this on ThingWorx 8.1 it is returning the ClientIP i.e. depending on where my mashup was accessed it picked up IP from that client. As per the source code it is suppose to return the client's IP.

Which ThingWorx version are you working with?

wcui16-PearlAuthorAnswer
16-Pearl
January 29, 2018

Hi Sushant, thanks for your comment. Actually this issue has been resolved with below results. Please take a ref.

1. By checking the coding, I found function <GetCurrentIPAddress> works as below.

  • Firstly it tries to return the value of XFF(x-forwarded-for) field from HTTP header.
  • If header does not contain XFF field, the IP, which web server(Tomcat) finally receives, will be returned.

2. I tested with Squid proxy server in 2 converse patterns.

    This proxy production can adds or does not add XFF filed into HTTP header according to your configuration.

  • When adding XFF, function returned client IP.
  • When no XFF, function returned proxy server IP.

Below is Wikipedia explanation for XFF usage with Proxy server/Load Balancers, just FYI.

wcui16-PearlAuthor
16-Pearl
February 8, 2018

Closed. Please Refer to Correct Answer for details.