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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

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

wcui
14-Alexandrite

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

Accepted Solutions
wcui
14-Alexandrite
(To:supandey)

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
supandey
19-Tanzanite
(To:wcui)

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?

wcui
14-Alexandrite
(To:supandey)

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.

wcui
14-Alexandrite
(To:supandey)

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

wcui
14-Alexandrite
(To:wcui)

Closed. Please Refer to Correct Answer for details.

Top Tags