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] Azure Service Bus "Unable to cast object of type 'Microsoft.Azure.Amqp.Framing.Accepted'" #45055

Closed
JoeGaggler opened this issue Jul 17, 2024 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@JoeGaggler
Copy link

JoeGaggler commented Jul 17, 2024

Library name and version

Azure.Messaging.ServiceBus 7.17.5

Describe the bug

I am experiencing the same issue as reported in #14836 - however that issue is locked, and so I am refiling this bug.

Stacktrace:

System.InvalidCastException: Unable to cast object of type 'Microsoft.Azure.Amqp.Framing.Accepted' to type 'Microsoft.Azure.Amqp.Transaction.Declared'.
   at Microsoft.Azure.Amqp.Transaction.Controller.DeclareAsync(CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpTransactionEnlistment.OnCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpTransactionManager.EnlistAsync(Transaction transaction, AmqpConnectionScope connectionScope, TimeSpan timeout)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchInternalAsync(AmqpMessage batchMessage, TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchInternalAsync(AmqpMessage batchMessage, TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<>c.<<SendAsync>b__24_0>d.MoveNext()
--- End of stack trace from previous location ---

Expected behavior

App code appears to be correct and is not throwing exceptions, so the expectation is that the ServiceBus library not throw either.

Actual behavior

Exception is thrown and caught internally, but operations might not be succeeding.

Reproduction Steps

using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionScopeAsyncFlowOption.Enabled))
{
	await receiver.SetSessionStateAsync(binaryData, cancellationToken);
	await serviceBusSender.SendMessageAsync(outMessage, cancellationToken); // THROWS HERE! Note: in and out have same session id
	await receiver.CompleteMessageAsync(inMessage, CancellationToken.None);
	transactionScope.Complete();
}

Environment

Azure Container App
Base Image: mcr.microsoft.com/dotnet/aspnet:8.0

@JoeGaggler JoeGaggler changed the title [BUG] [BUG] Azure Service Bus "Unable to cast object of type 'Microsoft.Azure.Amqp.Framing.Accepted'" Jul 17, 2024
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus labels Jul 17, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@JoeGaggler
Copy link
Author

We have enabled AzureEventSourceListener, which logs these at the same time as the exceptions:

Forwarding Azure Event: 92, TransactionDischargeException, Azure-Messaging-ServiceBus, transactionId(String)=222d15f3-cb67-441a-a38f-516870a395f6:388, amqpTransactionId(String)=, exception(String)=Azure.Messaging.ServiceBus.ServiceBusException: TransactionID is null or empty Reference:69c73c38-5818-447c-8fdb-ca9f94602a04, TrackingId:781780e6-d9ad-47a2-95ea-dab3b67105aa_G28, SystemTracker:gtm, Timestamp:2024-07-17T16:22:13 (GeneralError). For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.
Forwarding Azure Event: 3, SendMessageException, Azure-Messaging-ServiceBus, identifier(String)={{{REDACTED}}}, exception(String)=System.InvalidCastException: Unable to cast object of type 'Microsoft.Azure.Amqp.Framing.Accepted' to type 'Microsoft.Azure.Amqp.Transaction.Declared'.
   at Microsoft.Azure.Amqp.Transaction.Controller.DeclareAsync(CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpTransactionEnlistment.OnCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpTransactionManager.EnlistAsync(Transaction transaction, AmqpConnectionScope connectionScope, TimeSpan timeout)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchInternalAsync(AmqpMessage batchMessage, TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchInternalAsync(AmqpMessage batchMessage, TimeSpan timeout, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<>c.<<SendAsync>b__24_0>d.MoveNext()
Forwarding Azure Event: 89, TransactionInitializeException, Azure-Messaging-ServiceBus, transactionId(String)=222d15f3-cb67-441a-a38f-516870a395f6:388, exception(String)=System.InvalidCastException: Unable to cast object of type 'Microsoft.Azure.Amqp.Framing.Accepted' to type 'Microsoft.Azure.Amqp.Transaction.Declared'.
   at Microsoft.Azure.Amqp.Transaction.Controller.DeclareAsync(CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Amqp.AmqpTransactionEnlistment.OnCreateAsync(TimeSpan timeout, CancellationToken cancellationToken)

@jsquire
Copy link
Member

jsquire commented Jul 17, 2024

@JoeGaggler: Thanks for reaching out and we regret that you're experiencing difficulties. Looking over the previous issue and implementation, this appears to be something in the AMQP transport library that Service Bus uses as a dependency. I've transferred this over to the repository where the Microsoft.Azure.Amqp library is maintained as #262 so that the folks best able to assist have visibility.

@jsquire jsquire closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

3 participants