2012-01-19 35 views
1

我在開發機器上構建了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

請幫我解決這個錯誤。任何幫助將是可觀的。謝謝。

+0

防火牆?...... –

+0

我已關閉客戶端機器甚至生產服務器機器的防火牆,但沒有工作... –

+0

有必要關閉兩臺機器的防火牆..沒有關閉防火牆會讓我的應用程序工作 –

回答

0

我的建議是不要使用WSDualHttpBinding的雙工 - 它使用的整個模型是很容易失敗,並且不通過任何強勁配置的防火牆

開關雙工工作NetTcpBinding的。客戶端創建到服務器的出站連接,然後使用相同的連接傳遞雙工消息(WSDualHttpBinding嘗試建立從服務器到客戶端的另一個連接,這幾乎肯定會在生產網絡中被阻塞

我在這篇博客上發了文章here

+0

是richard,我們的應用程序在沒有disa的情況下無法工作bling防火牆,儘管數據同步服務器到客戶端反之亦然。應用程序有時會給出奇怪的服務模型異常,並在應用程序崩潰之後。 –

+0

正如我所說的,WSDualHttpBinding很漂亮,需要建立從服務器到客戶端的連接。但是,您需要了解雙工的常見問題 - 這是基於會話的模型,因此會話可以在任一端超時(超時由兩端的receiveTimeout控制,默認爲10分鐘)可以這是你的問題? –

+0

正如你所說的使用net.tcp binding for duplex wcf。現在它的工作,但當我看到主要的問題是訪問這個服務在窗口7機器它的工程很好。但在某些客戶端窗口XP機器出現錯誤。 endpointnotfound異常。我真的很困惑,爲什麼發生這種情況,因爲這個服務可以訪問窗口7和一些窗口xp,因爲我知道,但一些窗口xp機器不能打開代理..... plase給我建議..我必須做的工作這項服務在所有主要的SP2和SP3窗口7和窗口XP機器上。 –

相關問題