Azure EventHub 发送者发送消息失败
Azure EventHub sender fails to send messages
我使用最新的 WindowsAzure.ServiceBus
nuget 包和简单的代码片段从我的云服务 WebRole api 控制器向 Azure EventHub 发送消息:
var eventData = new EventData(buffer) { PartitionKey = partition };
await _eventHubClient.SendAsync(eventData);
一段时间后,发件人无法发送消息,我每次尝试发送消息时都会在日志中看到以下异常:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException:
An error occurred during communication with 'N/A'. Check the connection information, then retry.
---> System.InvalidOperationException: Failed with error code 0xe.
Server stack trace: at Microsoft.ServiceBus.Tracing.EventSource..ctor(Boolean disableTracing)
at Microsoft.ServiceBus.Tracing.MessagingClientEtwProvider.get_Provider()
at Microsoft.ServiceBus.Messaging.Amqp.Sasl.SaslTransportProvider.AddHandler(SaslHandler handler)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpTransportSettings.CreateAmqpSettings(String sslHostName, Int32 maxFrameSize, Boolean forceTokenProvider)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.<GetAsyncSteps>d__13.MoveNext()
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start() Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.End(IAsyncResult result, ConnectInfo& info)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.CreateAsyncResult.<>c.<GetAsyncSteps>b__5_1(CreateAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
Exception rethrown at [1]:
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.OpenLinkAsyncResult.<>c.<GetAsyncSteps>b__35_3(OpenLinkAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessageSender.OnEndOpen(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.ClientEntity.EndOpen(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.OpenComplete(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1..ctor(OpenOnceManager openOnceManager, TimeSpan openTimeout, AsyncCallback callback, Object state, Func`3 beginOperation, EndOperation`1 endOperation)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.Begin(AsyncCallback callback, Object state, Func`3 beginOperation, Action`1 endOperation)
at Microsoft.ServiceBus.Messaging.MessageSender.BeginSendEventData(TrackingContext trackingContext, IEnumerable`1 eventDatas, TimeSpan timeout, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.EventHubClient.<>c__DisplayClass32_0.<SendAsync>b__0(AsyncCallback c, Object s)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)
at Microsoft.ServiceBus.Common.Parallel.TaskHelpers.CreateTask(Func`3 begin, Action`1 end, Object state)
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
似乎一旦发件人偶然发现此错误,它就无法再发送消息了。
错误代码 0xE 来自 ERROR_OUTOFMEMORY 跟踪。作为解决方法,您可以扩展 Web 角色实例或完全禁用跟踪。
我也提交了一个错误来修复我们客户端的这个问题。基本上,消息传递操作不应由于跟踪问题而失败。
我使用最新的 WindowsAzure.ServiceBus
nuget 包和简单的代码片段从我的云服务 WebRole api 控制器向 Azure EventHub 发送消息:
var eventData = new EventData(buffer) { PartitionKey = partition };
await _eventHubClient.SendAsync(eventData);
一段时间后,发件人无法发送消息,我每次尝试发送消息时都会在日志中看到以下异常:
Microsoft.ServiceBus.Messaging.MessagingCommunicationException:
An error occurred during communication with 'N/A'. Check the connection information, then retry.
---> System.InvalidOperationException: Failed with error code 0xe.
Server stack trace: at Microsoft.ServiceBus.Tracing.EventSource..ctor(Boolean disableTracing)
at Microsoft.ServiceBus.Tracing.MessagingClientEtwProvider.get_Provider()
at Microsoft.ServiceBus.Messaging.Amqp.Sasl.SaslTransportProvider.AddHandler(SaslHandler handler)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpTransportSettings.CreateAmqpSettings(String sslHostName, Int32 maxFrameSize, Boolean forceTokenProvider)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.<GetAsyncSteps>d__13.MoveNext()
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state) at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start() Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.End(IAsyncResult result, ConnectInfo& info)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.CreateAsyncResult.<>c.<GetAsyncSteps>b__5_1(CreateAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
Exception rethrown at [1]:
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.OpenLinkAsyncResult.<>c.<GetAsyncSteps>b__35_3(OpenLinkAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception) at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessageSender.OnEndOpen(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.ClientEntity.EndOpen(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OnEndCreateInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.OpenComplete(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1..ctor(OpenOnceManager openOnceManager, TimeSpan openTimeout, AsyncCallback callback, Object state, Func`3 beginOperation, EndOperation`1 endOperation)
at Microsoft.ServiceBus.Messaging.OpenOnceManager.Begin(AsyncCallback callback, Object state, Func`3 beginOperation, Action`1 endOperation)
at Microsoft.ServiceBus.Messaging.MessageSender.BeginSendEventData(TrackingContext trackingContext, IEnumerable`1 eventDatas, TimeSpan timeout, AsyncCallback callback, Object state) at Microsoft.ServiceBus.Messaging.EventHubClient.<>c__DisplayClass32_0.<SendAsync>b__0(AsyncCallback c, Object s)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl(Func`3 beginMethod, Func`2 endFunction, Action`1 endAction, Object state, TaskCreationOptions creationOptions)
at Microsoft.ServiceBus.Common.Parallel.TaskHelpers.CreateTask(Func`3 begin, Action`1 end, Object state)
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
似乎一旦发件人偶然发现此错误,它就无法再发送消息了。
错误代码 0xE 来自 ERROR_OUTOFMEMORY 跟踪。作为解决方法,您可以扩展 Web 角色实例或完全禁用跟踪。
我也提交了一个错误来修复我们客户端的这个问题。基本上,消息传递操作不应由于跟踪问题而失败。