我在Window Server 2013上的Windows服务中托管了WCF服务。 安装并使服务运行正常,我可以使用Visual Studio进行连接。
当我运行我的应用程序时,我得到了打开超时异常。我浏览了一下网页,我在这里添加了追踪信息。 Self hosting wcf with nettcp exception
查看生成的日志,我会看到错误的详细信息。
无法连接到net.tcp:// ServerName:8001 / MessagingService / service。连接尝试持续时间跨度为00:00:21.0691067。 TCP错误代码10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应ServerIP:8001。
我正在使用net.tcp绑定,我已经为服务器上的服务打开了端口8000,8001的入站和出站。这没有改变。我还设置服务规则以允许任何端口,这没有任何区别。
服务器配置文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<system.serviceModel>
<services>
<service name="EMS.Messaging.Service.ChatService" behaviorConfiguration="MessagingServiceBehaviour">
<endpoint address="" binding="netTcpBinding" contract="EMS.Messaging.Service.IChat" bindingConfiguration="tcpBinding"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ServerName:8000/MessagingService/service" />
<add baseAddress="net.tcp://ServerName:8001/MessagingService/service" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MessagingServiceBehaviour">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding" maxBufferSize="67108864" maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864" transferMode="Buffered" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:20:00" sendTimeout="00:01:00" maxConnections="100" portSharingEnabled="true">
<security mode="None"/>
<readerQuotas maxArrayLength="67108864" maxBytesPerRead="67108864" maxStringContentLength="67108864" />
<reliableSession enabled="true" inactivityTimeout="00:20:00" />
</binding>
</netTcpBinding>
<customBinding>
<binding name="mexBinding">
<tcpTransport maxPendingConnections="100">
<connectionPoolSettings groupName="default" maxOutboundConnectionsPerEndpoint="100"/>
</tcpTransport>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>