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

v4.0.0 - CreateConnection() within WebAPI Controller #239

Closed
conradcreel opened this issue Aug 23, 2016 · 5 comments · Fixed by #240
Closed

v4.0.0 - CreateConnection() within WebAPI Controller #239

conradcreel opened this issue Aug 23, 2016 · 5 comments · Fixed by #240
Assignees
Milestone

Comments

@conradcreel
Copy link

The following code hangs at CreateConnection() when placed inside of a WebAPI endpoint using v4.0.0 of RabbitMQ.Client. Confirmed it works with v3.6.5. Further confirmed that the exact same code works when called in Application_Start but not in Application_BeginRequest using v4.0.0.

Using latest ASP.NET WebAPI/OWIN and .NET 4.6.1.

       var factory = new ConnectionFactory
        {
            HostName = "localhost",
            UserName = "XXX",
            Password = "YYY"
        };

        string queueName = "ZZZ";

        var args = new Dictionary<string, object>();
        args.Add("x-dead-letter-exchange", "TTT");
        args.Add("x-dead-letter-routing-key", queueName);
        string message = "Current time: " + DateTime.Now.ToLongTimeString();

        using (var connection = factory.CreateConnection())
        using (var channel = connection.CreateModel())
        {
            channel.QueueDeclare(queueName, true, false, false, args);

            var body = Encoding.UTF8.GetBytes(message);

            channel.BasicPublish(exchange: "",
                routingKey: queueName,
                basicProperties: null,
                body: body);
        }
@michaelklishin
Copy link
Member

Please post a traffic capture with both versions.

@kjnilsson
Copy link
Contributor

I suspect we may have fallen foul of the async/await deadlock problem when using task schedulers other than the default one. I will perform some additional testing using winforms and/or web api to see if I can replicate it.

@kjnilsson
Copy link
Contributor

@infinutrition there is now a release candidate for 4.0.1 available on nuget.org for you to try: https://www.nuget.org/packages/RabbitMQ.Client/4.0.1-rc1

@conradcreel
Copy link
Author

@kjnilsson Initial tests show that the 4.0.1 RC1 works, thank you both for the quick action.

@michaelklishin
Copy link
Member

@infinutrition thank you for reporting it and helping us verify.

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