Unknown port reported to WCF for remote client

I have an IIS enabled WCF service that is configured with a WebHttpBinding. This is the same VS2008 standard WCF service created when creating a new one. The only changes I made was to allow it to be called from javascript.

In the test method GetData (int value), I return a string that displays the IP address, port and useragent of the remote clients. Everything works fine except that I am not expecting the port number it returns. I am expecting port 80, but instead I get something like 49353. Below is the method I am calling.

public string GetData(int value)
    {
        OperationContext context = OperationContext.Current;

        MessageProperties messageProperties = context.IncomingMessageProperties;
        RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;



        return string.Format("Hello {0}! \r\naddress: {1}\r\nport: {2}\r\nuseragent: {3}", 
            value, endpointProperty.Address, endpointProperty.Port, WebOperationContext.Current.IncomingRequest.UserAgent);
    } 

      

As I said, I am calling this method from javascript. IIS is configured for port 80, so I'm not sure why the port is being reported incorrectly.

+1


source to share


1 answer


I think you might have it a little back. Port 80 is where you are listening, but as soon as it does, it sends that message to a new ephemeral port to handle that connection.



In addition, the client is also likely to use an ephemeral port to open a connection to port 80. Thus, the client port is most likely some "random" port number outside of the usual "fixed" port range (0-1024).

+3


source







All Articles