Rohit
Rohit

Reputation: 10226

WCF exception while connecting

I have added WPF Application to WCF Class library and my App config in WCF is as follows

  <service name="WCFChatApplication.Service1">
    <host>
      <baseAddresses>
        <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WCFChatApplication/Service1/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address ="" binding="wsDualHttpBinding" contract="WCFChatApplication.IMessageServiceInbound">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>

and my WPF app cpnfig is

    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IMessageServiceInbound" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                <security mode="Message">
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsDualHttpBinding>
    </bindings>

But when I call

 ServiceReference1.MessageServiceInboundClient Sc1 = new ServiceReference1.MessageServiceInboundClient(new InstanceContext(this),"WSDualHttpBinding_IMessageServiceInbound");
            Sc1.Open();

The error I get is

HTTP could not register URLhttp://+:80/Temporary_Listen_Addresses/9b1e11c2-0c91-43a6-9a17-26f473a9fdbc/ because TCP port 80 is being used by another application.

The process using port 80 is Inetinfo.exe.I cant seem to close this process.

Is there a way I can move from port 80 to any other port.

Thanks

Upvotes: 2

Views: 1448

Answers (3)

CodeCaster
CodeCaster

Reputation: 151588

You're using a duplex binding, so the client has to set up an address where the server can reach it. By default it seems to use port 80, which is in use by IIS.

Set the clientBaseAddress of the binding to another address and you should be good to go. Make sure the port is accessible on the client from the server (firewall, port forwarding et al).

Upvotes: 2

Emond
Emond

Reputation: 50672

My guess is that Visual Studio is trying to host the WCF service and this causes a conflict with the hosting done by your application.

Open the properties of the WCF project.

Open the WCF options tab.

Uncheck the first checkbox (Start WCF Service Host when debugging another project in the same solution)

Upvotes: 0

Related Questions