我有一個帶netTcp綁定的WCF服務。這是我的第一個WCF服務,我在端點方面遇到了一些問題。WCF,netTcp和Visual Studio 10
我在開發階段的目標是使用端口轉發從我的開發機器中公開服務。我已將IIS7默認網站配置爲在端口12345上偵聽TCP,並創建了必要的綁定。端口在我的防火牆上打開,端口在路由器上轉發。 Net.TCP服務全部運行。我想我已經採取了在這裏的文章推薦的所有步驟!
但是,當我嘗試在Visual Studio 10採用SVC文件的IP地址服務中添加服務引用它會創建這樣一個端點,指着我的本地主機名(火神):
<client>
<endpoint address="net.tcp://vulcan:12345/CloudnetService/Dispatcher.svc"
binding="netTcpBinding" bindingConfiguration="netTcpBinding_IDispatcher"
contract="CloudnetService.IDispatcher" name="netTcpBinding_IDispatcher" />
</client>
這當然適用於本地,但顯然不在互聯網上。
我的第二個問題是,雖然我實施的服務在本地很好地工作,但它似乎從外面看不到。 Telnet localhost 12345找到該服務。 Netstat顯示端口正在偵聽TCP。但是當我Telnet我的IP和端口時,我得到「無法打開與主機的連接,端口12345:連接失敗」。
這是從我的web.config中的system.serviceModel部分(---. ---。-。 - 是我的IP地址的佔位符):
<bindings>
<netTcpBinding>
<binding name="netTcpBinding_IDispatcher"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxReceivedMessageSize="65536">
<readerQuotas
maxDepth="32"
maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession
ordered="true"
inactivityTimeout="00:10:00" />
<security mode="None">
<message
clientCredentialType="None"
algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Service.Dispatcher">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="netTcpBinding_IDispatcher"
contract="Service.Interfaces.IDispatcher"
name="netTcpBinding_IDispatcher">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://---.---.-.--:12345/CloudnetService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
作爲新手,我相信我在做一些非常基本的錯誤!
許多在此先感謝。 陶
感謝Lex - 這是令人清醒的建議。我想要一個異步雙工。我可能不得不退縮。 :-( – 2012-08-02 06:49:25
爲什麼不使用WSDualHttpBinding?雖然使用WS信封,但它提供了相同的功能。 – 2012-08-02 06:59:47
我嘗試了WSDualHttpBinding,但無法通過我的NAT獲得異步回調,netTcp提供了開箱即用的功能。工作!我的端口問題是通過路由器的硬重置來解決的,我編輯了Visual Studio的app.config來包含IP地址和presto,但我很清楚你的防火牆評論, – 2012-08-02 07:52:04