【问题标题】:WCF service errors out on other machines in the same networkWCF 服务在同一网络中的其他计算机上出错
【发布时间】:2014-11-28 14:32:12
【问题描述】:

我开发了一个使用 WCF 服务的 C# 控制台应用程序。在本地机器上一切正常。当我创建设置文件并分发 exe 和 exe.config 文件时,应用程序在同一网络上的其他机器上出错,并出现以下错误:

通信对象 System.ServiceModel.Channels.ServiceChannel 不能用于通信,因为它处于故障状态..

WCF 服务端点 URL - http://inblrlwssc251.wdf.corp:7980/AfariaService/Server 也可以从 其他机器 访问。不确定会出现什么问题。

服务的配置如下,我使用的是 WSHTTP 绑定:

 <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>

非常感谢任何帮助或正确方向的指针。

【问题讨论】:

  • 您提到的错误不是问题的原因。问题是,它是如何进入故障状态的?如果不捕获和记录原始异常,就无法判断。我认为您确实捕获了异常,但您仍然尝试将客户端用于其他调用。 (WCF 调用期间的异常会使您的客户端进入故障状态。当您再次尝试使用此客户端时,您会遇到无法再使用它的异常。)
  • @fejesjoco 是在正确的道路上。服务中的任何 未处理 异常都会使通道处于故障状态,并且无法使用故障通道 - 需要重新创建一个新通道。检查您的服务 - 查看您拥有的任何日志,检查事件查看器以查看是否记录了任何内容并启用 WCF 跟踪都是研究根本原因的方法。
  • 感谢 fejesjoco 和 Tim,问题已解决。我没有通过正确的凭据来访问 WCF 服务。

标签: c# wcf wcf-wshttpbinding


【解决方案1】:

我知道这是旧的,您说它已解决,但为了后代,这通常不是传递错误凭据的结果。通常,这是由于服务器响应的结果是您配置为在缓冲区中接受的更多数据,超过了 maxitemsinobject 图,或者服务器的响应时间过长,导致异常,已处理。 .. 这个异常是下一次调用的结果(正如 fejesjoco 和 Tim 指出的那样)。

出现这种情况时,最好重新初始化client/serviceclient对象(对于这个api,也调用initContext),然后再尝试调用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 2012-12-11
    • 1970-01-01
    相关资源
    最近更新 更多