C# 当其他服务按预期工作时,wsDualHttpBinding始终超时
我目前开发了几个服务(WCF)来与TFS2010合作 其中一些使用事件订阅工具,而另一些则通过sharepoint门户、小型wpf应用程序等使用 我正在开发一个应用程序来管理另一台服务器中的某些内容,例如向服务器发送IIS重置请求,并且我正在使用wsDualHttpBinding,这样我就可以通过回调向用户发送所有事情的进展情况 但我甚至不能调用服务中的方法,因为每当通道尝试打开时,我都会出现超时异常,无论我的OpenTimeout是什么 这是我的配置(客户端) 服务(未发布代码,因为问题发生在到达之前): 在fiddler中,我在客户端得到了以下信息:C# 当其他服务按预期工作时,wsDualHttpBinding始终超时,c#,wcf,timeout,duplex,wsdualhttpbinding,C#,Wcf,Timeout,Duplex,Wsdualhttpbinding,我目前开发了几个服务(WCF)来与TFS2010合作 其中一些使用事件订阅工具,而另一些则通过sharepoint门户、小型wpf应用程序等使用 我正在开发一个应用程序来管理另一台服务器中的某些内容,例如向服务器发送IIS重置请求,并且我正在使用wsDualHttpBinding,这样我就可以通过回调向用户发送所有事情的进展情况 但我甚至不能调用服务中的方法,因为每当通道尝试打开时,我都会出现超时异常,无论我的OpenTimeout是什么 这是我的配置(客户端) 服务(未发布代码,因为问题发生在
7202http-tfsserver:8080/DeployService/ResetService.svc 0 private-resetman.vshost:9000
我多次得到202,然后时间流逝,超时发生
在服务器上运行fiddle,我什么也得不到
可能会发生什么
编辑:奇怪,localhost工作正常。wsDualHttpBinding需要特殊权限吗?在“互联网”上找不到任何东西试试看
ConcurrencyMode=ConcurrencyMode.Reentrant
InstanceContextMode=InstanceContextMode.Single
- 删除
SessionMode.Required
关于您的服务行为由于您使用的是
wsDualHttpBinding
,因此您的服务器和客户端都需要在配置中指定的端口上可访问。这就是它在本地机器上工作的原因,因为您没有任何端口问题。超时与防火墙阻塞或服务器无法路由回客户端一致
如果您的客户端可以通过添加防火墙或端口转发规则轻松访问,那么wsDualHttpBinding
可能仍然适用-否则使用wsDualHttpBinding可能并不理想。在这种情况下,您可能需要让客户机轮询消息,而不是通过回调接收消息(即客户机拉取消息,而不是通过回调推送消息)
更多信息请参见帖子。还有一个。我也遇到了同样的问题。 在客户端应用程序中的以下代码的帮助下,我通过将绑定配置传递给服务解决了这个问题。这将给你一个如何实现目标的想法。它在我的大多数系统中都适用,但在某些系统中仍然存在超时问题。可能原因无法绑定端口
Service objService = new Service(objClass, "WSDualHttpBinding_ISendChatService");
WSDualHttpBinding binding = objService.Endpoint.Binding as WSDualHttpBinding;
int portNumber = FreeTcpPort();
string hostName = Dns.GetHostName();
binding.ClientBaseAddress = new Uri("http://"+Dns.GetHostByName(hostName).AddressList[0].ToString()+":" + portNumber + "/");
objService.Start(name);
static int FreeTcpPort()
{
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}
@不,我最终使用了
wsHttpBinding
并不时轮询服务器的状态。
<?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>
[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
}
Service objService = new Service(objClass, "WSDualHttpBinding_ISendChatService");
WSDualHttpBinding binding = objService.Endpoint.Binding as WSDualHttpBinding;
int portNumber = FreeTcpPort();
string hostName = Dns.GetHostName();
binding.ClientBaseAddress = new Uri("http://"+Dns.GetHostByName(hostName).AddressList[0].ToString()+":" + portNumber + "/");
objService.Start(name);
static int FreeTcpPort()
{
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
return port;
}