0

In our project we are using WCF service sometimes we are getting exception port is being used.I have searched for that all I found is error will come with duplex connection and have to use clientBaseAddress attribute as specified in this link

So Can anyone have idea how to resolve this for WSHttpBinding??

My app.config file code is as shown below.

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
  <service behaviorConfiguration="MyStandardServiceBehave" name="Services.TestService">
    <endpoint address="http://localhost:8080/TestService"
      binding="wsHttpBinding" bindingConfiguration="standardServiceConfiguration"
      contract="ServiceContracts.ICommonService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/TestService" />
      </baseAddresses>
    </host>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="standardServiceConfiguration"
           maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
      <readerQuotas maxDepth="2147483647" maxBytesPerRead="2147483647"
       maxArrayLength="2147483647" maxStringContentLength="2147483647" />
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyStandardServiceBehave">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
    </behavior>
  </serviceBehaviors>
</behaviors>    

NAGASREE
  • 286
  • 3
  • 13

1 Answers1

1

You are not using any duplex connections (wsDualHttpBinding). You are using a simple wsHttpBinding. So it has nothing to do with that.

It just has to do with the fact that the port is already in use by another application (As the error message already told you).

A port can only be used by one process. Therefore, you must either stop the existing process or use a port other than 8080 for your WCF service.

See here to find out which application is using your port.

Marc
  • 3,739
  • 4
  • 19
  • 34
  • So Can I change dynamically the port used by WCF Service? – NAGASREE May 17 '19 at 10:10
  • You can set everything dynamically and without a config file, but not change a port at runtime if you mean that... And if the service use different ports each time, your clients also need to be aware of that. What is stopping you from just taking another free port? – Marc May 17 '19 at 10:19
  • I am seeing this error sometimes only and on some machines..How can we know the port which will be free on all users machine?? – NAGASREE May 17 '19 at 10:26
  • Can you please share how to set port dynamically..because my application have both client and server config files access – NAGASREE May 17 '19 at 10:56
  • 1
    Are you hosting a service on each user machine? I thought you are talking about a service that's hosted on one server. If yes, please describe the full scenario in your question and maybe I can give you a suitable answer for that. – Marc May 17 '19 at 11:05
  • Yes..in our application we are running certain libraries as WCF service and our application is only client which access this libraries.In one application we have both client and service – NAGASREE May 17 '19 at 11:12
  • 1
    Please create a new question for that, because this is very different from what you have asked here. Your question was specific to the "port in use" problem. Now you need to setup an architecture where different clients needs to communicate via dynamic ports. There is a lot more to do then. – Marc May 17 '19 at 12:05