When calling the WCF web service from a C # client (System.ServiceModel.ClientBase <> instance), how can I get the IP address of the server I'm connected to?
Context: we set up a web farm for some WCF services, and I need to know which specific server I'm connected to when an exception occurs.
You can add this to your catch:
IPHostEntry heserver = Dns.GetHostEntry(Dns.GetHostName()); IPAddress curAdd = heserver.AddressList[0]; curAdd.ToString();
Your load balancer is probably hiding a specific web server from you.
A common strategy is to log errors on the server and use some kind of log aggregator for operations to monitor all servers.
, , . , .