gpt4 book ai didi

wcf - wcf 的超时异常或默认连接限制?

转载 作者:行者123 更新时间:2023-12-04 21:43:41 26 4
gpt4 key购买 nike

我首先为我的 WCF 服务启动了我的订阅者,然后继续发布我的发布者的帖子。我的订阅者能够收到帖子。

其次,我关闭了我的第一个订阅者并再次打开它以订阅相同的服务,即所谓的已订阅该服务的第二个订阅者。再一次,它能够接收一个帖子。

一旦我重复第三次,就会有异常(exception)

The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout.

总结:

  1. 在第一个客户端上,已订阅,一切正常
  2. 关闭第一个客户端
  3. 在 cilent AGAIN 上,(意味着同一服务上的第二个连接(?)),一切正常
  4. 关闭“第二个客户端”
  5. 第三次打开客户端,出现错误

根据我目前的研究,我看到在这个问题中,它提到默认连接限制是 2?

WCF Service Throttling

这是导致我出错的问题吗?如果是,是否可以调整连接限制以及如何调整?

在 WCF 领域很新,欢迎任何人给我他们的意见。谢谢!

编辑

尝试在我的客户端上使用 UseSynchronizationContext = false。每次发送帖子时,我的订阅者的 PostReceived() 方法包括打开一个包含帖子信息的弹出窗口窗体。使用 UseSynchronizationContext = false 时,windows 窗体将无法正常打开(此处出错)。

有人知道如何解决这个问题或有任何替代解决方案吗?

编辑 2

阅读了大量与 WCF 连接相关的内容,发现大多数人都试图在他们的配置文件中切换 maxConnections 变量或相关内容。我的问题是我拥有的唯一配置文件在我的客户端中,而我的服务项目没有。我是否需要为我的服务项目添加配置文件?

由于“连接限制”(?) 是 2,我尝试了在客户端退出应用程序时取消订阅它的方法,但这不起作用并给我和错误。我已经发布了一个关于我收到的错误的问题。

https://stackoverflow.com/questions/8395525/objectdisposedexception-on-wcf-service

添加了客户端的配置代码:

<system.serviceModel>
<diagnostics performanceCounters="All" />
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPostingContract" clientBaseAddress="http://localhost:8000/wcfClient/" closeTimeout="00:01:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10: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:8888/PostingContract/Posting"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IPostingContract"
contract="IPostingContract" name="WSDualHttpBinding_IPostingContract">
<identity>
<userPrincipalName value="##" />
</identity>
</endpoint>
</client>

</system.serviceModel>

如果我的服务部分在行为或配置文件方面做错了什么,有人会建议我吗?欣赏一百万。谢谢!

编辑 3

设法玩弄服务行为。对于该行为,我将 InstanceContextMode 更改为单一。

InstanceContextMode = InstanceContextMode.Single

这实际上允许我启动我的 Windows 窗体应用程序的 2 个以上连接。但是,如果我这样做,如果我事先启动了 2 个连接,则对于第三个连接,它将收到 3 个弹出窗口,随后对于第四个连接,它将收到 4 个。假设它收到 1 个。

最佳答案

这有助于在客户端订阅者类上添加 UseSynchronizationContext = false

例如

[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant,
UseSynchronizationContext = false)]

原因可能是解除锁定回调类似的帖子在这里WCF: Having trouble with one-way callbacks

关于wcf - wcf 的超时异常或默认连接限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8376277/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com