Question
Tech Mahindra
CA
Last activity: 8 Feb 2016 3:34 EST
Sometimes unable to get the machine host name correctly instead getting IP address in place of host name
We are using pega 6.1 SP2. We have a requirement to capture the machine host name and IP address of requestors logged on to the machine and we used pxRequestor.pxReqRemoteHost property to hold the host name but sometimes we are getting IP address in pxReqRemoteHost property (Same IP address in pxReqRemoteAddr) but not sure of when. Can you please suggest us?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems
IN
Maybe this will help - http://stackoverflow.com/questions/3812166/difference-between-remote-host-and-remote-addr
Tech Mahindra
CA
Thanks Rajiv.
I believe host name and IP addresses fields in PRPC are depends on/same as the returned values from getHostName() and getRemoteAddr() methods in java. Correct if i am wrong.
Pegasystems Inc.
US
Adding to what Rajiv Nistala said, unless all client machines have registered hostname which can be reverse look up, it is unlikely that you can 100% insure pxReqRemotHost has a name instead IP address.
This might help http://stackoverflow.com/questions/3993021/client-computer-name-in-java
Tech Mahindra
CA
My machine is registered properly and we could see pxReqRemotHost set properly all the times with node specific URL but when it comes to generic URL (Uses load balancer to route to individual nodes), we see the issue consistently.
Pegasystems Inc.
US
In tomcat, one needs to change the configuration in Tomcat's server.xml file to enable hostname lookups. See Apache Tomcat 7 Configuration Reference (7.0.67) - The HTTP Connector and the "enableLookups" attribute. There may be a (noticeable) impact if the clients are remote.
I suspect other application servers may have similar settings / defaults. Can you check if this is enabled on all the nodes at your end?
More on enableLookups below:
Set to true
if you want calls to request.getRemoteHost()
to perform DNS lookups in order to return the actual host name of the remote client. Set to false
to skip the DNS lookup and return the IP address in String form instead (thereby improving performance). By default, DNS lookups are disabled.
Pegasystems Inc.
US
I was able to set up a load balancer on PRPC instance. I could see that pxReqRemoteHost held the IP address. However, when I set enableLookups to true on tomcat – pxReqRemoteHost showed the client’s hostname.
However, this did not work when I accessed PRPC using the load balancer url. So, I guess this is the root cause. Perhaps you could try checking if there is a similar setting (for DNS or reverse DNS lookup) in the load balancer configuration.
There is hard-coding in PRPC - we force a reverse DNS lookup in our own code. We have a prconfig setting in 63+ that can be hotfixed to 61 - http/reversednslookup
61sp2 port is hfix-5271
Tech Mahindra
CA
Does the above hotfix 5271 solevs our problem?
or should we need to check the configurations in all servers and load balancers.
Hi Rahul,
Thanks for updating the thread with the SR number!
-Lochan
Pegasystems Inc.
US
The hostname indicated by the pxReqRemoteHost property may be missing or inaccurate when proxy servers or other redirectors are in use (Reference).
Not sure if this is to do with Load Balancer but we notice the issue without Load Balancer too.