Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
WCF 3.5 RemoteEndpointMessageProperty in load balancing situation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Dow  
View profile  
 More options Jan 2 2009, 11:31 am
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
From: "John Dow" <john...@hotmail.com>
Date: Fri, 2 Jan 2009 10:31:50 -0600
Local: Fri, Jan 2 2009 11:31 am
Subject: WCF 3.5 RemoteEndpointMessageProperty in load balancing situation
I have a WCF service in .Net 3.5 and I am trying to use
RemoteEndpointMessageProperty to get the IP address of the client who
consume the service, for trouble shooting purposes:

OperationContext context = OperationContext.Current;
MessageProperties properties = context.IncomingMessageProperties;
RemoteEndpointMessageProperty endpoint =
properties[RemoteEndpointMessageProperty.Name] as
RemoteEndpointMessageProperty;
if (endpoint != null)
{
    IP = string.Concat(endpoint.Address, ":", endpoint.Port);

}

However, since the WCF service is hosted in IIS behind a load balancer, the
IP address I got is always the IP of the load balancer.
Is there any way to get around this so that I can get the true IP of the
client?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eyal.mo...@gmail.com  
View profile  
 More options Oct 14 2012, 10:59 pm
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
From: eyal.mo...@gmail.com
Date: Sun, 14 Oct 2012 19:59:27 -0700 (PDT)
Local: Sun, Oct 14 2012 10:59 pm
Subject: Re: WCF 3.5 RemoteEndpointMessageProperty in load balancing situation

 string retIp = "";
            try
            {

                OperationContext context = OperationContext.Current;

                MessageProperties prop = context.IncomingMessageProperties;

                HttpRequestMessageProperty endpointLoadBalancer =
                    prop[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;

                if(endpointLoadBalancer.Headers["X-Forwarded-For"]!=null)
                {
                    retIp = endpointLoadBalancer.Headers["X-Forwarded-For"];
                }

                if(string.IsNullOrEmpty(retIp))
                {
                    RemoteEndpointMessageProperty endpoint =
                        prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                    retIp = endpoint.Address;
                }
            }
            catch (Exception ex) {
                log.Error("Error in GetClientIP: " + ex.ToString());
            }
            return retIp;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »