2017-01-09 48 views
0

當我有一個使用Webjob擴展SDK一個webjob,那就是手動觸發並正在讀取/寫入服務總線功能懸掛。TopicClient發送使用蔚藍webjob SDK

發送郵件時似乎掛起。

這裏是有關的代碼:

JobHostConfiguration config = new JobHostConfiguration 
      { 
       StorageConnectionString = decryptedStorageConnectionString, 
       DashboardConnectionString = decryptedDashboardConnectionString, 
      }; 
      config.UseTimers(); 
      var host = new JobHost(config); 

      host.CallAsync(typeof(Program).GetMethod(nameof(myJob))); 

      // The following code ensures that the WebJob will be running continuously 
      host.RunAndBlock(); 

[NoAutomaticTrigger] 
     public void myJob(TextWriter log) 
     { 
... 
this.Client = TopicClient.CreateFromConnectionString(connection, ConstantStrings.IncidentResponseTopicName); 
this.Client.Send(args); 

} 

,我發現了以下錯誤:

The request operation did not complete within the allotted timeout of 00:01:09.7322175. The time allotted to this operation may have been a portion of a longer timeout. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:fdbd3e20-c1b7-4829-8ebd-b9b14962c13f, Timestamp:1/9/2017 10:14:07 AM 

System.TimeoutException: The request operation did not complete within the allotted timeout of 00:01:09.9496489. The time allotted to this operation may have been a portion of a longer timeout. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:570d2e9f-cd9f-4bb5-8d52-45ecf026df3f, Timestamp:1/9/2017 10:15:18 AM 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Server stack trace: 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [0]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<>c.<GetAsyncSteps>b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [1]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass8_1.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [2]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<>c.<GetAsyncSteps>b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [3]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<>c.<GetAsyncSteps>b__18_3(TIteratorAsyncResult thisPtr, IAsyncResult a) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [4]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndUpdateCommand(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.OnEndComplete(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] 
[01/09/2017 10:15:18 > ff1c90: INFO] Exception rethrown at [5]: 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.MessageReceiver.OnComplete(TrackingContext trackingContext, IEnumerable`1 lockTokens, TimeSpan timeout) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.MessageReceiver.Complete(TrackingContext trackingContext, IEnumerable`1 lockTokens, TimeSpan timeout) 
[01/09/2017 10:15:18 > ff1c90: INFO] at Microsoft.ServiceBus.Messaging.ReceiveContext.Complete() 
[01/09/2017 10:15:18 > ff1c90: INFO] at MyJob.myJob.<ExecuteJob>b__4_0(BrokeredMessage request) 

一切運作良好時,我用一個普通天青webjob。當我將代碼移到Azure Webjob SDK時,這個掛起就開始了。 另一個有趣的事情是,在我的本地機器上運行時,一切似乎都很順利,只有在將代碼部署到Azure Web角色時纔會發生這種情況。

任何想法???

+0

爲什麼你使用'host.CallAsync'?在你的例子中,該方法不是異步的。你是否確定連接字符串? – Thomas

+0

是的,當我在本地運行時,運行效果很好。 –

+0

你可以嘗試使用'host.Call'? – Thomas

回答

0

根據您的代碼,我假設您正在使用Azure WebJobs SDK Extensions > TimerTrigger來安排您的其他工作,並且在JobHost啓動時手動調用myJob函數來讀取/寫入服務總線的消息。

System.TimeoutException: The request operation did not complete within the allotted timeout of 00:01:09.9496489. The time allotted to this operation may have been a portion of a longer timeout.

正如官方document提到有關服務總線的消息TimeoutException

A TimeoutException indicates that a user-initiated operation is taking longer than the operation timeout. You should check the value of the ServicePointManager.DefaultConnectionLimit property, as hitting this limit can also cause a TimeoutException.

The server did not respond to the requested operation within the specified time which is controlled by OperationTimeout .

我認爲你可以嘗試增加OperationTimeout並添加重試邏輯如下建立你TopicClient

var builder = new ServiceBusConnectionStringBuilder("{ServicesBusConnectionString}") 
{ 
    OperationTimeout = TimeSpan.FromMinutes(10) 
}; 
var messagingFactory = MessagingFactory.CreateFromConnectionString(builder.ToString()); 
TopicClient topicClient = messagingFactory.CreateTopicClient("{TopicName}"); 
topicClient.RetryPolicy = new RetryExponential(
      TimeSpan.Zero, 
      TimeSpan.FromMinutes(5), 
      2); 
topicClient.Send("{BrokeredMessage}"); 
+0

感謝布魯斯但這並沒有幫助。另外,相同的代碼運行完全找到locallyf只有當部署到蔚藍failes webjob。 另一個有趣的事情是,當我調用該函數,而無需使用蔚藍SDK擴展一切正常,部署時也是如此。所以,這種感覺就像在蔚藍webjob錯誤 –