我在開發機器上構建了WCF雙工服務。我構建了這個服務,創建了一個測試客戶端,測試了一切,並且它工作正常。然後我大膽地將它移到我的生產服務器上。現在我已經轉移到生產服務器,我不能使用雙工服務。塊了一段時間,並給超時錯誤雙工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 = "[email protected]";
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
請幫我解決這個錯誤。任何幫助將是可觀的。謝謝。
防火牆?...... –
我已關閉客戶端機器甚至生產服務器機器的防火牆,但沒有工作... –
有必要關閉兩臺機器的防火牆..沒有關閉防火牆會讓我的應用程序工作 –