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?
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.
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.
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.
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.
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.