我在开发机器上构建了WCF双工服务。我构建了服务,创建了一个测试客户端,测试了所有内容并且工作正常。 。然后我得到了勇气并将它移动到我的生产服务器。现在我已经转移到生产服务器我无法使用双工服务。阻止一段时间并给出超时错误
服务web.config
<?XML version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<compilation debug="true" target Framework="4.0">
</compilation>
<authentication mode="Windows"/>
<pages compatibility="3.5" client ID Mode="Auto ID"/>
</system.web>
<system.serviceModel>
<services>
<service name="WCFDuplex.Service1" behaviorConfiguration="WCFDuplex.Service1Behavior">
<endpoint address="http://Productionserver:8088/sampleWCF/Service1.svc" binding="wsDualHttpBinding" contract="WCFDuplex.IServiceDuplex">
<identity>
<dns value="Productionserver"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFDuplex.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
客户端app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IServiceDuplex" 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:01:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default"/>
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://Productionserver:8088/sampleWCF/Service1.svc" binding="wsDualHttpBinding"
bindingConfiguration="WSDualHttpBinding_IServiceDuplex" contract="IServiceDuplex"
name="WSDualHttpBinding_IServiceDuplex">
<identity>
<dns value="Productionserver" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
客户代码:
static void Main(string[] args)
{
EndpointAddress endPointAddress = new EndpointAddress("http://ProductionServer:8088/sampleWCF/Service1.svc");
try
{
InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
ServiceDuplexClient client = new
ServiceDuplexClient(instanceContext, new WSDualHttpBinding(), endPointAddress);
client.ClientCredentials.UserName.UserName = "bipin";
client.ClientCredentials.UserName.Password = "pass@123";
client.Open();
client.GetDataFromXml();
}
catch (Exception ex)
{
Console.WriteLine(string.Format("Error connecting to service. {0}", ex.Message));
}
Console.ReadLine();
}
我在开放代理时遇到错误:即client.Open();
客户端无法在配置的超时(00:00:00)内完成安全协商。当前的谈判支持是1(00:00:00)。源= mscorlib程序
请帮我解决这个错误。任何帮助都会很明显。感谢。
答案 0 :(得分:0)
我的建议是不要将WSDualHttpBinding用于Duplex - 它使用的整个模型很容易出现故障而无法通过任何可靠配置的防火墙工作
切换到NetTcpBinding以进行双工。客户端创建到服务器的出站连接,然后使用相同的连接传递双工消息(WSDualHttpBinding尝试建立从服务器到客户端的另一个连接,这几乎肯定会在生产网络中被阻止
我在博客上发表了这篇文章here