2011-11-10 43 views
2

我嘗試使用net.tcp綁定來設置服務進行測試。我還設置了一個http端點。配置如下:WCF net.tcp連接總是失敗

<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://本地主機:6969 /入站。連接嘗試持續時間爲00:00:00.9531494。 TCP錯誤代碼10061:由於目標機器主動拒絕它127.0.0.1:6969,因此無法建立連接。

順便說一句,http綁定工作正常。我認爲這可能是一些機器配置,但無法找到根本原因。

+1

你是如何託管你的服務? WAS?一個Windows服務? –

回答

3

如果您嘗試通過Visual Studio運行WCF服務,則不支持netTcpBinding。抱歉!

Check out this post for a more detailed explanation.

+0

你說得對。我不得不使用自己託管的控制檯應用程序來託管測試,即使在機器中停止Net.Tcp綁定服務,它也能正常工作。 –

0

爲什麼你忽略了客戶端的net.tcp地址的「.svc」?也許它應該是「net.tcp:// localhost:6969/Inbound.svc」

+1

我嘗試BOT方式,他們都不似乎工作:( –

0

什麼託管你使用..IIS7或控制檯或其他?

1)檢查所有TCP服務SERVICES.MSC

2)關閉您的防火牆或者添加防火牆例外您的TCP端口

,如果你正在主持在IIS7檢查此鏈接

正在運行

IIS7 support for non http protocols

+1

1)我使用ASP.Net開發服務器到我的機器上運行的應用程序 2)防火牆已經關閉 我注意到, Net.Tcp端口共享服務在我的機器上關閉,我會看看是否可以連接服務。 –

+0

您不能使用ASP.Net Development Server來託管net.tcp綁定,您必須使用iis7或控制檯託管。 – Anand