我有一个 WCF 服务托管在远程计算机上。在我的本地计算机上,我有一个 WPF 应用程序和一个 Windows 服务,我希望能够连接到 WCF 服务。 WPF 应用程序可以正常连接和通信,但由于某种原因,Windows 服务无法连接。它们的 app.config 文件是相同的,并且建立连接的代码也是相同的。 Windows 服务无法连接有什么原因吗?
这是我得到的异常:
套接字连接被中止。这可能是由于处理您的消息时出错或超过接收超时所致
远程主机或底层网络资源问题。本地套接字
超时为“00:01:14.9900000”。
奇怪的是,异常是在 5 秒内抛出的,而不是在超时设置的 1:15 之后。
这是应用程序配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ServiceIP" value="127.0.0.1"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:01:15"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8731/WCFService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBindingEndpoint" contract="WCFService.IWCFService"
name="NetTcpBindingEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
据我所知,追踪似乎没有透露任何有用的信息。
检查运行 Windows 服务的帐户。由于您要访问网络资源,因此您需要一个具有足够权限的域帐户来访问该资源(就像您登录的用户帐户一样)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)