【发布时间】:2014-01-22 11:28:19
【问题描述】:
我开发了 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>
【问题讨论】:
-
尝试显着增加所有超时。另外,您使用防火墙吗?
-
这是你得到的only错误吗?什么时候发生错误,当你执行一个资源繁重、耗时的方法时,或者还有一个
void Test()方法时? -
我已经将时间增加了 24 分钟,但仍然出现错误,@ athabaska。 @CodeCaster 我没有使用任何繁重的资源。除了这些,我还能做什么?
-
您可以从添加更多细节开始并查看正在发生的事情的细节,这没有灵丹妙药。首先,显示完整的异常。然后enable tracing 用于客户端和服务器,以查看请求的最终位置。该服务是否可以在您的开发机器上运行?如果你添加并调用一个实际上什么都不做的测试方法,它会起作用吗?
-
我曾尝试在 localhost 中托管并且成功,但是当我移动到服务器时,就会出现这个问题。