Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AmqpTransportInitiator.Complete is throwing a NullReferenceException #258

Closed
Chocanto opened this issue May 3, 2024 · 3 comments
Closed

Comments

@Chocanto
Copy link

Chocanto commented May 3, 2024

Hi,

After updating to the latest version (2.6.5) of Microsoft.Azure.Amqp (included in azure.messaging.servicebus starting 7.17.4) we are seeing more and more NullReferenceException being thrown when the internet connection is unstable. This makes our application crash multiple times per day.

We were not seeing this error at all in the previous versions.

We wonder if this bug could have been introduced in this commit: 843ab89. In particular the piece of code added in Microsoft.Azure.Amqp/Amqp/Transport/AmqpTransportInitiator.cs to change the type of exception when catching an ObjectDisposedException.

Please find below a stack trace of this exception:

Unhandled exception. Microsoft.Azure.Amqp.CallbackException: An AsyncCallback threw an exception.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.Complete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.OnTransportOpenCompete(IAsyncResult result)
   at Microsoft.Azure.Amqp.AsyncResult.TryComplete(Boolean didCompleteSynchronously, Exception exception)
   --- End of inner exception stack trace ---
   at Microsoft.Azure.Amqp.AsyncResult.TryComplete(Boolean didCompleteSynchronously, Exception exception)
   at Microsoft.Azure.Amqp.AmqpObject.CompleteOpen(Boolean syncComplete, Exception exception)
   at Microsoft.Azure.Amqp.Sasl.SaslTransport.OnNegotiationFail(Exception exception)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.CompleteTransport()
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.HandleException(String action, Exception exception)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.Microsoft.Azure.Amqp.IIoHandler.OnIoFault(Exception exception)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.HandleReadComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.ReadCore(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.ReadFrame()
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.ReadFrame()
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.OnWriteFrameComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.AsyncBufferWriter.HandleWriteComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.AsyncBufferWriter.Write(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.AsyncBufferWriter.WriteBuffer(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.WriteFrame(Performative command, Boolean needReply)
   at Microsoft.Azure.Amqp.Sasl.SaslAnonymousHandler.OnStart(SaslInit init, Boolean isClient)
   at Microsoft.Azure.Amqp.Sasl.SaslHandler.Start(SaslNegotiator saslNegotiator, SaslInit init, Boolean isClient)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.OnSaslServerMechanisms(SaslMechanisms mechanisms)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.HandleSaslCommand(Performative command)
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.Microsoft.Azure.Amqp.IIoHandler.OnReceiveBuffer(ByteBuffer buffer)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.HandleReadComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.ReadCore(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.FrameBufferReader.ReadFrame()
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.ReadFrame()
   at Microsoft.Azure.Amqp.Sasl.SaslNegotiator.Start()
   at Microsoft.Azure.Amqp.Sasl.SaslTransport.OpenInternal()
   at Microsoft.Azure.Amqp.AmqpObject.OpenAsyncResult.OnStart()
   at Microsoft.Azure.Amqp.AmqpObject.AmqpObjectAsyncResult.Start()
   at Microsoft.Azure.Amqp.AmqpObject.BeginOpen(TimeSpan timeout, CancellationToken cancellationToken, AsyncCallback callback, Object state)
   at Microsoft.Azure.Amqp.AmqpObject.BeginOpen(TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.OnReadHeaderComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.AsyncBufferReader.HandleReadComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.AsyncIO.AsyncBufferReader.OnReadComplete(TransportAsyncCallbackArgs args)
   at Microsoft.Azure.Amqp.Transport.TlsTransport.HandleOperationComplete(IAsyncResult result, Boolean write, Boolean syncComplete)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(ContextCallback callback, Object state, Task& currentTask)

Thank you for your help!

@xinchen10
Copy link
Member

Thanks for reporting the issue. Yes your analysis is correct. It should be a regression from the exception conversion change. We will fix it and release a new package.

@xinchen10
Copy link
Member

Released 2.6.6

@Chocanto
Copy link
Author

Chocanto commented May 4, 2024

Thank you very much for this quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants