我有一个使用Webjob扩展名sdk的webjob,以及一个手动触发并正在读/写服务总线的函数。
发送邮件时似乎挂起了。
这是相关代码:
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)
当我使用常规的Azure webjob时,一切都运行良好。当我将代码移动到Azure Webjob SDK时,这个挂起就开始了。 另一个有趣的事情是,在本地计算机上运行时,一切似乎都运行良好,只有在将代码部署到Azure Webjobs时才会发生这种情况
任何想法???
答案 0 :(得分:0)
根据您的代码,我假设您正在使用Azure WebJobs SDK Extensions > TimerTrigger来安排其他工作,并在JobHost时手动调用myJob
函数来从/向服务总线读/写消息启动。
System.TimeoutException:请求操作未在分配的超时00:01:09.9496489内完成。分配给此操作的时间可能是较长超时的一部分。
正如官方document中提到的关于服务总线消息TimeoutException
:
TimeoutException表示用户启动的操作所花费的时间超过了操作超时。 您应该检查ServicePointManager.DefaultConnectionLimit属性的值,因为达到此限制也会导致TimeoutException。
服务器未在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}");