一种愚蠢的错误,但是当我想通过服务器端服务(WCF Duplex)调用客户端时发生这种情况:
无法在分配的wcf回调超时00:01:00内传输消息,可靠频道的传输窗口中没有可用空间
也是mysterious happened too
。在我调用服务的登录方法中,如果用户和密码错误,我找到发送者回调,然后在发件人上调用GetError
方法,以显示“用户错误”等逻辑错误。这很好用,但是如果用户和密码是正确的并且有访问权限,那我就得到了这个错误(对于所有其他客户端方法都是一样的 - 在所有这些方法中,我发送的数据比简单字符串多,我发送的是geterror)!
编辑2:正如我在大多数回调方法中所说,我发送的数据类似于数据上下文(LINQ to SQL)数据类(列表或单行)。那么这可能是我的问题! (但这不是我第一次使用WCF-duplex,也使用回调方法中的send data-struct,我真是太惊人了。)
此错误后,我收到了此错误,
屏幕无法处理来自服务http://server:15450/service.svc灾难性故障的请求
编辑3: 服务配置:
<system.serviceModel>
<services>
<service name="ContactServer.Business.ContactService"
behaviorConfiguration="ServiceBehavior">
<endpoint address=""
binding="wsDualHttpBinding"
contract="ContactServer.Business.IContactService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
name="MexBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
和客户端配置
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ContactService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1408/ContactService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ContactService"
contract="ServiceReference.ContactService" name="WSDualHttpBinding_ContactService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
更多信息:我使用.NET 3.5和Visual Studio 2010.在客户端上升超时后,我仍然遇到同样的错误,with 00:01:00 Time
。为什么会这样?
答案 0 :(得分:2)
问题在于从WCF服务转移实体。
例如,我们有这个数据库模型:
实体框架:
public Item GetItem(int id)
{
var se = new SampleEntities();
return se.Items.FirstOrDefault(i => i.Id == id);
}
代码似乎没有错,但实际上它会返回包含所有相关项目的项目。
var s = new SampleServiceClient();
var item = s.GetItem(1);
Assert.AreEqual(item.RelatedItems.Any(), true); //equal
如果数据库中存在多对多关系,则尤其危险。 因此应该禁用延迟加载(您可以在返回之前禁用它们):
var se = new SampleEntities();
se.ContextOptions.LazyLoadingEnabled = false;
return se.Items.FirstOrDefault(i => i.Id == id);
Linq to SQL
public Item GetItem(int id)
{
var dc = new DataClasses1DataContext();
return dc.Items.FirstOrDefault(i => i.Id == id);
}
我们有一个例外:
尝试序列化参数时出错:GetItemResult。 InnerException消息是'类型的对象图'WebApplication1.RelatedItem'包含循环,如果禁用参考跟踪,则无法序列化。'。
您必须打开DataContext diagramm并设置Properties-&gt; SerializationMode-&gt; Unindirectional。 Here是一个更完整的解释。