简体   繁体   中英

WCF service errors out on other machines in the same network

I developed a C# console application that consumes a WCF service. All works fine on the local machine. When I created the set up files and distributed the exe and exe.config files, the application errors out on other machines on the same network with the below error:

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state..

The WCF service endpoint URL - http://inblrlwssc251.wdf.corp:7980/AfariaService/Server is accessible form other machines as well. Unsure what can be going wrong.

The configuration for the service looks as below, I use the WSHTTP binding:

 <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true"
          logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <bindings>
      <netNamedPipeBinding>
        <binding name="NetNamedPipeBinding_IServerService" />
      </netNamedPipeBinding>
      <netTcpBinding>
        <binding name="NetTcpBinding_IServerService">
          <security mode="Message" />
        </binding>
      </netTcpBinding>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IServerService" />
      </wsHttpBinding>
    </bindings>
    <!-- 
      Modify the "adress" in each of the endpoint tags based on where the Afaria API service is hosted
    -->
    <client>
      <endpoint address="http://inblrlwssc251:7980/AfariaService/Server"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServerService"
          contract="AfariaServerService.IServerService" name="WSHttpBinding_IServerService">
      </endpoint>
      <endpoint address="net.tcp://inblrlwssc251:7982/AfariaService/Server"
          binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IServerService"
          contract="AfariaServerService.IServerService" name="NetTcpBinding_IServerService">
      </endpoint>
      <endpoint address="net.pipe://localhost/AfariaService/Server"
          binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IServerService"
          contract="AfariaServerService.IServerService" name="NetNamedPipeBinding_IServerService">
      </endpoint>
    </client>
  </system.serviceModel>

Any help or a pointer in the right direction will be very much appreciated.

I know that this is old and you said it is resolved, but for posterity's sake this is not typically the result of passing incorrect credentials. Normally this is a result of the response from the server responding with more data that you've configured to accept in your buffers, exceeding the maxitemsinobject graph, or the response from the server taking too long, which causes an exception, which is handled... and this exception is the result of the next call (as fejesjoco and Tim pointed out).

When this occurs, it is best to reinitialize the client/serviceclient object (for this api, also call initContext) and then try the call again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM