【问题标题】:WCF net.tcp connection always failsWCF net.tcp 连接总是失败
【发布时间】:2011-12-26 02:49:27
【问题描述】:

我尝试使用 net.tcp 绑定设置用于测试的服务。我还设置了一个 http 端点。配置如下:

  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Inbound_REST">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="InboundHttpConfiguration">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="InboundTcpConfiguration">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="InboundTcpConfiguration" name="Inbound">
          <endpoint address="" binding="netTcpBinding" contract="IContract">
            <identity>
              <dns value="localhost"/>
            </identity>
          </endpoint>
          <host>
            <baseAddresses>
              <add baseAddress="net.tcp://localhost:6969/Inbound" />
            </baseAddresses>
          </host>
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint name="httpEndPoint" address="http://localhost:1568/Inbound.svc" binding="basicHttpBinding" contract="IContract" />
       <endpoint name="tcpEndPoint" address="net.tcp://localhost:6969/Inbound" binding="netTcpBinding" contract="IContract" />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding name="httpbind">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="tcpbind">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

当我尝试使用 net.tcp 绑定使用服务时,它总是返回错误:

无法连接到 net.tcp://localhost:6969/Inbound。连接尝试持续了 00:00:00.9531494 的时间跨度。 TCP错误代码10061:无法建立连接,因为目标机器主动拒绝了它127.0.0.1:6969。

顺便说一下,http 绑定工作正常。我认为这可能是某些机器配置,但无法找到根本原因。

【问题讨论】:

  • 您如何托管您的服务?曾是? Windows 服务?

标签: wcf nettcpbinding


【解决方案1】:

如果您尝试通过 Visual Studio 运行 WCF 服务,则不支持 netTcpBinding。对不起!

Check out this post for a more detailed explanation.

【讨论】:

  • 你是对的。我必须创建一个自托管的控制台应用程序来托管测试,它工作正常,即使 Net.Tcp 绑定服务在机器中停止。
【解决方案2】:

您正在使用什么主机..IIS7 或控制台或其他?

1)检查services.msc中所有的tcp服务是否正在运行

2)关闭防火墙或将防火墙例外添加到您的 tcp 端口

如果您在 iis7 中托管,请查看此链接

IIS7 support for non http protocols

【讨论】:

  • 1) 我正在使用 ASP.Net 开发服务器来运行应用程序 2) 我机器上的防火墙已经关闭 我注意到我的机器上的 Net.Tcp 端口共享服务已关闭,我'看看服务是否可以连接。
  • 您不能使用 ASP.Net 开发服务器来托管 net.tcp 绑定,您必须使用 iis7 或控制台托管。
【解决方案3】:

为什么您为客户端的 net.tcp 地址省略了“.svc”?也许应该是“net.tcp://localhost:6969/Inbound.svc”

【讨论】:

    猜你喜欢
    • 2017-10-16
    • 2015-04-22
    • 2015-12-26
    • 2010-09-28
    • 2012-09-11
    • 1970-01-01
    • 2016-04-02
    • 1970-01-01
    • 2019-02-21
    相关资源
    最近更新 更多