Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
400 stars 143 forks source link

Sending an AMQP message from an ASP.NET 4.7.2 page request context #553

Closed go81816 closed 1 year ago

go81816 commented 1 year ago

Hello, I am trying to use AMQPNetLite.Core to send a message to a queue from two different applications. One use case is from a request to an ASP.NET Core web api application which works as expected. The other use case is from a page in an ASP.NET 4.7.2 MVC application which results in an InvalidOperationException with HRESULT 0x80131509 which indicates that an asynchronous operation can’t be started at this time. The ASP.NET Core application is calling from an asynchronous controller function while the ASP.NET MVC application only uses synchronous controller functions, but both applications use the AMQPNetLite synchronous api.

I did some digging through the AMQPNetLite code and found an async void function called TransportWrite which I am not 100% certain is being used for my use cases however it does seem to be called from non async functions and async void functions are mentioned specifically as a potential cause of the exception I’m receiving.

Do you think it makes sense to avoid using async void functions in AMQPNetLite?