tags:

views:

1517

answers:

6

We have a WCF service deployed on a Windows 2003 server that is exhibiting some problems. The configuration is using wsHttpBinding and we are specifying the IP address. The services is being hosted by a Windows Service.

When we start the service up, most of the time it grabs the wrong IP address. A few times it bound to the correct address only to drop that binding and go to the other address (there are 2) bound to the NIC after processing for a short while.

It is currently using port 80 (we've configured IIS to bind to only 1 address via httpcfg) although we have tried it using different ports with the same results.

When the Windows Service starts hosting the WCF service, the properties show that it is being bound to the correct address; however, tcpview shows that it is indeed listening on the incorrect address.

Here is the portion of the config that sets up tehe baseAddress. The one that gets bound to ends up being .4 instead of .9

   <services>
        <service name="Service.MyService"
                 behaviorConfiguration="serviceBehavior">
            <host>
                <baseAddresses>
                    <add baseAddress="http://xx.xx.xx.9:80/" />
                </baseAddresses>
            </host>
            <endpoint address="MyService"
                      binding="wsHttpBinding"
                      bindingConfiguration="WSHttpBinding_IMyService"
                      contract="Service.IMyService" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
        </service>
    </services>

Is there some other configuration that needs to be set? Is there a tool that can help track down where this is getting bound to the wrong address?

Thanks in advance

+1  A: 

Your WCF configuration looks OK to me. This might be an issue with the binding order of your NIC cards. Make sure that the NIC with correct address is first. Here is an article that discuss how to set and view nic binding orders:

http://theregime.wordpress.com/2008/03/04/how-to-setview-the-nic-bind-order-in-windows/

aogan
There are 2 NIC's; however one is disabled. both IP's are bound to the only enabled NIC.I did try the ordering but it did not fix the problem.
palehorse
A: 

More information: I removed the xx.xx.xx.4 IP address from the NIC altogether and turned off IIS. Now when I try to start the service it fails and I find this in the System event log.

Description:
Unable to bind to the underlying transport for xx.xx.xx.4:80. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine.  The data field contains the error number.

My configuration file still has the xx.xx.xx.9 baseAddress setting.

palehorse
A: 

One more piece of informatoin. If we change the binding to use NetTcp instead of WsHttp it binds to the correct address on port 80. Changing it back to WsHttp it goes back to the incorrect IP address.

palehorse
+1  A: 

The issue seems to be ISS related. Here is the description about the error your getting from http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/ddf72ae0-aa1e-48c9-88d1-10bae1e87e4f.mspx?mfr=true

This error is logged to the event log when HTTP.sys parses the IP inclusion list and finds that all of the entries in the list are invalid. If this happens, as the description in Table 11.15 notes, HTTP.sys listens to all IP addresses.

You can also check the following thread which talks about a similiar issue http://www.webhostingtalk.com/showthread.php?t=534174

Hope this helps.

aogan
As stated in the original problem, we've already used httpcfg as described in your links to tell IIS to listen only on the xx.xx.xx.4 address.
palehorse
The problem is that as long as we are using wsHttpBinding the WCF service also uses the xx.xx.xx.4 address rather than the xx.xx.xx.9 address that is specified in the configuration file.
palehorse
Changing to netTcpBinding causes the service to bind to the correct xx.xx.xx.9 addres; however, we would like to use wsHttpBinding as non-WCF clients will need to use this service.
palehorse
+1  A: 

We had the same issue and this feature helped us to solve our problem :

http://msdn.microsoft.com/en-us/library/system.servicemodel.hostnamecomparisonmode.aspx

Hope this help.

PulsarBlow
A: 

BaseAddress is ignored. You need to set a host header under IIS.

Junto