我开发了一个WCF服务,但是我遇到了从客户端连接到它的问题。
我能够在浏览器中看到服务的wsdl
,但是当我尝试通过WCF客户端连接服务时,我收到以下错误消息:
在分配的超时00:23:59.5339734内未完成打开操作。分配给此操作的时间可能是较长超时的一部分。
以下是我的客户端app.config详细信息: -
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IService" closeTimeout="00:25:00" openTimeout="00:24:00" receiveTimeout="00:15:00" sendTimeout="00:25:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="409600" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:25:00"/>
<security mode="None">
<!--<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>-->
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://silcore.co.in/Service.svc"
binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IService"
contract="IService"
name="WSDualHttpBinding_IService">
<identity>
<dns value="http://silcore.co.in"/>
</identity>
</endpoint>
</client>
这是超时错误的堆栈跟踪:
at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.Open()
at WCF_Client.Program.Main(String[] args)
服务器端web.congif文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" defaultLanguage="c#" />
<customErrors mode="Off" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="Service.svc" />
</files>
</defaultDocument>
</system.webServer>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="DualNewBinding" />
</wsDualHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="HostWCF.ServiceBehavior" name="HostWCF.Service">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DualNewBinding" contract="HostWCF.IService">
<identity>
<dns value="silcore.co.in" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://silcore.co.in/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HostWCF.ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
答案 0 :(得分:1)
我说服务背后的操作真的需要很长时间。是否预计需要24分钟? 如果是这样,请增加超时,或者,您应该进行异步操作。
如果24分钟无法预期,请尝试更改操作立即返回。它现在有效吗?如果是,那么这是你的操作需要很长时间,你需要找出如何以及为什么。
如果没有,您可能遇到防火墙/网络问题。服务器或中间的某个人可能不会拒绝您的连接而只是忽略它。要调试此尝试暂时停用安全性。 此外,请确保是否在服务器端收到请求。放置断点或记录任何传入的请求。
希望它有所帮助
答案 1 :(得分:0)
我认为您需要在客户端配置中增加OpenTimeOut的值。
检查天气是否有任何防火墙阻止服务器上的呼叫
此外,我觉得服务器端的某种日志记录或网络监控工具也可以帮助你
NetMon是微软的一款不错的工具。试试那个