MassTransit: Remote RabbitMQ Connection Timeout using .NET Core 2.0
I am not sure if this is due to Core 2.0 but I can run it fine on non core.
The code I am using is below.
Options
"RabbitMQ": {
"Host": "rabbitmq://192.168.160.131/",
"Username": "test",
"Password": "1"
},
Bus
var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
{
var host = cfg.Host(new Uri(_rabbitMQOptions.Host), h =>
{
h.Username(_rabbitMQOptions.Username);
h.Password(_rabbitMQOptions.Password);
});
cfg.ReceiveEndpoint(host, nameof(TestCommand), e =>
{
e.Consumer(() =>
{
return new TestConsumer();
});
e.PrefetchCount = 2;
});
});
_logger.LogInformation("Starting bus");
busControl.Start();
_logger.LogInformation("Bus started");
_logger.LogInformation("Waiting for messages");
Command & Consumer
public class TestCommand
{
}
public class TestConsumer : IConsumer<TestCommand>
{
public TestConsumer()
{
}
public async Task Consume(ConsumeContext<TestCommand> context)
{
Console.WriteLine("Consumed");
}
}
When I run the code, it fails with
'Connect failed: test@192.168.160.131:5672/'
TimeoutException: The operation has timed out.
This issue occurs with both 3.5.7 and 4.0.0.1216-develop.
I have confirmed that I can connect fine by following the rabbitmq hello world tutorial.
Each connection creates the following log entries in rabbitmq.
=INFO REPORT==== 25-Jul-2017::05:00:19 ===
accepting AMQP connection <0.31858.0> (192.168.160.1:51098 -> 192.168.160.131:5672)
=ERROR REPORT==== 25-Jul-2017::05:00:19 ===
closing AMQP connection <0.31858.0> (192.168.160.1:51098 -> 192.168.160.131:5672):
{handshake_timeout,handshake}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 37 (17 by maintainers)
@phatboyg I have been using the pre-release package on netcore1.1 and netcore2 without any issue. think we can close this issue.
I’m going to close this, enough have it working with core that this isn’t an MT issue.
My understanding is waiting on a RabbitMQ.Client update.
Does
bus.StartAsync()work? To my understanding timeout is caused by deadlock , occuring due to single threadedSynchronizationContextin bus.start() and lack of .ConfigureAwait(false) in RabbitMq client. Created PR in client’s repo.