2015-05-13 46 views
1

我正在使用此博客文章中給出的代碼構建Azure服務總線的POC:http://blogs.msdn.com/b/tomholl/archive/2011/10/09/using-service-bus-topics-and-subscriptions-with-wcf.aspx但是,我收到以下錯誤。Azure服務總線主題超時異常

System.TimeoutException:請求在00:00:00毫秒後超時。請求的成功完成無法確定。應進行其他查詢以確定操作是否成功。

我所做的一切都是爲每個鏈接。這裏是我的代碼,我收到此行錯誤:((IChannel)clientChannerl)。開();

 var accountEventLog = new AccountEventLog() 
     { 
      AccountId = 123, 
      EventType = "BE", 
      Date = DateTime.Now 
     }; 

     ChannelFactory<IAccountEventNotification> factory = null; 
     try 
     { 
      factory = new ChannelFactory<IAccountEventNotification>("Subscribers"); 
      var clientChannerl = factory.CreateChannel(); 
      ((IChannel)clientChannerl).Open(); 

      using (new OperationContextScope((IContextChannel)clientChannerl)) 
      { 
       var bmp = new BrokeredMessageProperty(); 
       bmp.Properties["AccountId"] = accountEventLog.AccountId; 
       bmp.Properties["EventType"] = accountEventLog.EventType; 
       bmp.Properties["Date"] = accountEventLog.Date; 
       OperationContext.Current.OutgoingMessageProperties.Add(BrokeredMessageProperty.Name, bmp); 

       clientChannerl.onEventOccurred(accountEventLog); 
      } 

      ((IChannel)clientChannerl).Close(); 
      factory.Close(); 
     } 
     catch (Exception ex) 
     { 
      Console.WriteLine(ex.ToString()); 
     } 

這裏是我的配置設置

<behaviors> 
     <endpointBehaviors> 
     <behavior name="securityBehavior"> 
      <transportClientEndpointBehavior> 
      <tokenProvider> 
       <sharedSecret issuerName="RootManageSharedAccessKey" issuerSecret="Shared Key Here" /> 
      </tokenProvider> 
      </transportClientEndpointBehavior> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors>  
    <bindings> 
     <netMessagingBinding> 
     <binding name="messagingBinding" sendTimeout="00:03:00" receiveTimeout="00:03:00" 
        openTimeout="00:03:00" closeTimeout="00:03:00" sessionIdleTimeout="00:01:00" 
        prefetchCount="-1"> 
      <transportSettings batchFlushInterval="00:00:01" /> 
     </binding> 
     </netMessagingBinding> 
    </bindings> 
    <client> 
     <endpoint name="Subscribers" 
       address="sb://Namespace/topicname" 
       binding="netMessagingBinding" 
       bindingConfiguration="messagingBinding" 
       contract="My Contract" 
       behaviorConfiguration="securityBehavior" /> 
    </client> 

任何幫助將高度讚賞

回答

1

我能解決這個問題。但是,我將描述我在整個練習中學到的內容。

  1. 令牌提供者的行爲增加用於與ACS(Active Directory服務)服務總線驗證
  2. 命名空間使用Azure的門戶網站不創建默認的ACS端點/ ACS認證創建。當您創建名稱空間時,它僅默認創建SAS(共享訪問簽名)。
  3. 來驗證使用SAS使用您的WCF調用此令牌提供者:< sharedAccessSignature的keyName = 「RootManageSharedAccessKey」 鍵= 「」/>
  4. 如果你想使用ACS認證,然後使用Azure的創建命名空間電源外殼。以下是PS命令與ACS認證創建命名空間啓用:

    新AzureSBNamespace「命名空間」,「東美」 -CreateACSNamespace $真-NamespaceType消息

因此,要解決我的問題,我用點3如上所述,並開始工作。

0

另一件事看出來的,是已經有人不小心留在你的App.config或Web.config中啓用了代理?這將在發送時產生類似的異常。

查找類似以下內容:

<system.net> 
    <defaultProxy enabled="true" useDefaultCredentials="true"> 
     <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" /> 
    </defaultProxy> 
    </system.net> 
相關問題