我们有一个带有ServiceBus绑定(主题/订阅)的Azure函数,当在服务总线上放置新消息时会触发该函数。
我们偶尔(一天一次)在与服务总线相关的Azure功能的应用程序见解中看到异常。它本身似乎与我们的Azure函数中的代码没有任何联系,但看起来像是一些潜在的连接问题。
我们应该如何处理这些错误以及如何解决/克服它们?
一些例子:
Microsoft.ServiceBus.Messaging.MessagingException:
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver+ReceiveAsyncResult+<>c.<GetAsyncSteps>b__12_5 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.OnEndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult+<>c.<GetAsyncSteps>b__15_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult.TryReceiveEnd (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver.EndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver.EndReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceivePump+PumpAsyncResult+<>c.<GetAsyncSteps>b__7_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Inner exception System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] handled at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand:
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.ThrowIfFaultMessage (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.HandleMessageReceived (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+<>c.<GetAsyncSteps>b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel+RequestAsyncResult+<>c__DisplayClass8_1.<GetAsyncSteps>b__4 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+<>c.<GetAsyncSteps>b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
另一个例子:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException:
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult.TryReceiveEnd (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver.EndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceiver.EndReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.MessageReceivePump+PumpAsyncResult+<>c.<GetAsyncSteps>b__7_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
Inner exception System.ServiceModel.CommunicationObjectFaultedException handled at Microsoft.ServiceBus.Common.AsyncResult.End:
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+<>c.<GetAsyncSteps>b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel+RequestAsyncResult+<>c__DisplayClass8_1.<GetAsyncSteps>b__4 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+<>c.<GetAsyncSteps>b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
答案 0 :(得分:0)
它们看起来像是由某种网络级中断引起的通常为间歇性异常。根据Microsoft文档Exception types中的指定,这些分类为“ 暂时异常”:
临时异常(... MessagingException, .... MessagingCommunicationException)。一般动作:重试 操作或通知用户。请注意,
RetryPolicy
类在 客户端SDK可以配置为自动处理重试。看到 Retry guidance以获得更多信息。
尽管,我喜欢称它们为Ghostceptions
。
根据Exception types section,以下是这些异常的常见情况和建议的操作:
MessagingException
- 尝试使用属于不同实体类型(例如,主题)的名称或路径来创建QueueClient。
- 尝试发送大于256 KB的消息。服务器或服务在处理请求期间遇到错误。
检查代码,并确保仅可序列化的对象用于消息正文(或使用自定义序列化程序)。在文档中查看属性的受支持的值类型,并且仅使用受支持的类型。检查
IsTransient
属性。如果为true
,则可以重试该操作。MessagingCommunicationException
- 客户端无法建立与服务总线的连接。
确保提供的主机名正确且主机可访问。