gpt4 book ai didi

c# - wsDualHttpBinding 总是超时,而其他服务按预期工作

转载 作者:太空宇宙 更新时间:2023-11-03 14:07:43 24 4
gpt4 key购买 nike

我目前正在开发多项服务 (WCF) 以使用 TFS 2010。

其中一些使用事件订阅工具,而另一些则通过sharepoint 门户、小型wpf 应用程序等进行消费。

我正在开发一个应用程序来管理另一台服务器中的某些内容,例如向服务器发送 IIS 重置请求,并且我正在使用 wsDualHttpBinding,因此我可以在一切发生时通过回调向用户发送进度消息。

但我什至无法调用服务中的方法,因为每当 channel 尝试打开时,无论我的 OpenTimeout 是多少,我都会收到超时异常。

这是我的配置(客户端)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<connectionManagement>
<add maxconnection="200" address="*" />
</connectionManagement>
</system.net>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IReset" closeTimeout="00:01:00"
openTimeout="00:02: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="None">
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsDualHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IDeploy" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="1524288" maxReceivedMessageSize="1279748152"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="81925" maxArrayLength="163848"
maxBytesPerRead="9192" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://tfsserver:8080/TFSFacade/DeployFacade.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDeploy"
contract="DeployFacade.IDeploy" name="WSHttpBinding_IDeploy" />
<endpoint address="http://tfsserver:8080/DeployService/ResetService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IReset"
contract="ResetService.IReset" name="WSDualHttpBinding_IReset" />
</client>
</system.serviceModel>
<appSettings>
<add key="CopiaLocalRollback" value="true"/>
<add key="CopiaLocalPublish" value="true"/>
<add key="ModoDiagnostico" value="false" />
<add key="TempoTimeout" value="300000" />
</appSettings>
</configuration>

服务器端:

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://tfsserver:8080"/>
<add prefix="http://tfsservices:8080"/>
<add prefix="http://tfsservices:1001"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ResetService" 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="None">
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="EventServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="EventServiceBehavior" name="DeployService.ResetService">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ResetService"
contract="DeployService.Contracts.IReset" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

契约(Contract):

[ServiceContract(SessionMode = SessionMode.Required,
CallbackContract = typeof(IResetCallback))]
public interface IReset
{
[OperationContract]
void ExecutarIISReset();
}

[ServiceContract]
public interface IResetCallback
{
[OperationContract(IsOneWay = true)]
void PumpMessage(string message);

[OperationContract(IsOneWay = true)]
void PumpResponsiveMessage(ResponsiveMessage message);

[OperationContract(IsOneWay = true)]
void PumpLogDeployBEMessage(LogDeployBE message);

bool Confirmar();

ServidorModel[] GetServidores();
}

服务(未发布代码,因为问题发生在到达之前):

[AspNetCompatibilityRequirementsAttribute(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ResetService : IReset
{
//Stuff here
}

在 fiddler 中,我在客户端得到这个:

7 202 HTTP tfsserver:8080/DeployService/ResetService.svc 0 private resetman.vshost:9000

我多次得到202,然后时间过去,发生超时

在服务器上运行 fiddle,我什么也得不到。

可能发生了什么?

编辑: 很奇怪,本地主机有效。 wsDualHttpBinding 是否需要特殊权限或其他什么?在“互联网”上没有找到任何内容

最佳答案

由于您使用的是 wsDualHttpBinding,因此您的服务器都需要在您的配置中指定的端口上可访问。这就是它在本地计算机上运行的原因,因为您没有任何端口问题。超时与防火墙阻塞或您的服务器无法路由回您的客户端一致。

如果您的客户端可以通过添加防火墙或端口转发规则轻松访问,那么 wsDualHttpBinding 可能仍然适用 - 否则使用 wsDualHttpBinding 可能并不理想。在这种情况下,您可能需要让客户端轮询消息而不是通过回调接收消息(即客户端拉取消息而不是通过回调推送消息)

参见 this发布更多。还有this一个。

关于c# - wsDualHttpBinding 总是超时,而其他服务按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8880492/

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