cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
Amethyst

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

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.
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

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

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.

View solution in original post

4 REPLIES 4

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

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?

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

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.

View solution in original post

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

sorry I skipped your question, I tested with TWX 7.2.

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

Closed. Please Refer to Correct Answer for details.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________