【问题标题】:wcf tcp: error 10061wcf tcp: 错误 10061
【发布时间】:2012-06-28 19:18:32
【问题描述】:

我有一个服务,其中包含两个我想与 tcp 绑定一起使用的合同。服务配置文件是这样的:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="ServiceDocumentos" transferMode="Streamed"
                 maxBufferSize="67108864"
                      maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
                   closeTimeout="00:00:10"
                       openTimeout="00:00:10" receiveTimeout="00:20:00"
                       sendTimeout="00:01:00" maxConnections="100"/>
        <binding name="ServiceCore" transferMode="Buffered"
                 maxBufferSize="67108864"
                      maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864"
                   closeTimeout="00:00:10"
                       openTimeout="00:00:10" receiveTimeout="00:20:00"
                       sendTimeout="00:01:00" maxConnections="100"/>
      </netTcpBinding>

      <basicHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom" transferMode="Streamed"  />
        <binding name="ServiceCore" messageEncoding="Mtom" transferMode="Buffered" />
      </basicHttpBinding>

      <wsDualHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom"/>
        <binding name="ServiceCore" messageEncoding="Mtom"/>
      </wsDualHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="CMMSService" name="GTS.CMMS.Service.Service">
        <endpoint binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
                 name="ServiceDocumentos" contract="GTS.CMMS.Service.IServiceDocumentos"
         address="ServiceDocumentos/">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address ="net.tcp://localhost:6000/CMMSService/ServiceCore/"
                 binding="netTcpBinding" bindingConfiguration="ServiceCore"
                 name="ServiceCore" contract="GTS.CMMS.Service.IService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
                 listenUriMode="Explicit">
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8500/CMMSService" />
            <add baseAddress="net.tcp://localhost:8501/CMMSService" />
          </baseAddresses>
        </host>


      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="CMMSService">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

而客户端配置文件是:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="ServiceDocumentos" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="3670016" maxBufferPoolSize="524288" maxReceivedMessageSize="3670016"
         transferMode="Streamed">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
        <binding name="ServiceCore" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
         transferMode="Buffered">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </netTcpBinding>

      <basicHttpBinding>
        <binding name="ServiceDocumentos" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="3670016" maxBufferPoolSize="524288" maxReceivedMessageSize="3670016"
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
        <binding name="ServiceCore" closeTimeout="00:01:00" openTimeout="00:01:00"
         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2097152" maxBufferPoolSize="524288" maxReceivedMessageSize="2097152"
         messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="65536"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
             realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

      <wsDualHttpBinding>
        <binding name="ServiceDocumentos" messageEncoding="Mtom"/>
        <binding name="ServiceCore" messageEncoding="Mtom"/>
      </wsDualHttpBinding>
    </bindings>

    <client>
      <!--<endpoint address="net.tcp://localhost:8501/CMMSService/ServiceDocumentos/"
       binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
       contract="IServiceDocumentos" name="ServiceDocumentos" />
      <endpoint address="net.tcp://localhost:8501/CMMSService/ServiceCore/"
       binding="netTcpBinding" bindingConfiguration="ServiceCore"
       contract="IService" name="ServiceCore" />-->

      <endpoint address="net.tcp://localhost:8501/CMMSService/ServiceDocumentos/"
       binding="netTcpBinding" bindingConfiguration="ServiceDocumentos"
       contract="IServiceDocumentos" name="ServiceDocumentos" />
      <endpoint address="net.tcp://localhost:6000/CMMSService/ServiceCore/"
       binding="netTcpBinding" bindingConfiguration="ServiceCore"
       contract="IService" name="ServiceCore" />
    </client>
  </system.serviceModel>

我正在使用不同的绑定进行测试。例如,如果对于一个合同,IServiceDocumentos 我使用 tcp,而对于另一个合同,我使用 wsDualHttpBinding 的主合同,一切正常。我可以使用这两个合同。

如果我对这两个合约使用 tcp,则会收到错误 tcp 10061。

我尝试为每个合约使用单独的完整地址,因为我猜问题可能是使用相同的端口,但问题仍然存在。但是,如果我为每个端点使用一个完整的单独地址,那么如果我使用不同的绑定就可以了。

另外我尝试star一下服务tcp端口共享(windows XP中的服务),问题还是没有解决。

我尝试禁用防火墙,但这并不能解决问题。

谢谢。

编辑:

我在服务运行时使用以下命令:

netstat -ona || find "6000"

我得到以下信息:

TCP 0.0.0.0:6000 0.0.0.0 监听 2690

所以我认为 por 是打开并监听的。

【问题讨论】:

  • 错误10061 是“连接被拒绝”(WSAECONNREFUSED)。这意味着您尝试连接的计算机没有在监听。该应用程序是否在该计算机上运行?

标签: wcf tcp


【解决方案1】:

我认为您以错误的方式定义了服务端点的收件人。 只要您启用端口共享,您就不必为每个 tcp 地址使用不同的端口。 这是通过使用任何 .NET 3.0 安装上可用的 Net.TCP 端口共享服务来实现的。默认情况下,该服务未启用,因此您必须自己启用它。有关如何启用 Net.TCP 端口共享服务,请查看以下链接:http://msdn.microsoft.com/en-us/library/ms733925.aspx

【讨论】:

  • 我在启动服务的情况下进行测试,但我得到同样的错误,所以我认为问题不在于tcp端口的共享。我在原帖中添加了一些信息。
猜你喜欢
  • 1970-01-01
  • 2014-01-31
  • 2013-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多