vumani mdabe
vumani mdabe

Reputation: 43

Trying to connect to rabbitMQ in c# but getting a BrokerUnreachableException

Hi I'm having trouble connecting to rabbitMQ server, after following the tutorial on their site to here's my code below.

var factory = new ConnectionFactory() { HostName = "localhost" };
    using(var connection = factory.CreateConnection())
    using(var channel = connection.CreateModel())
    {
        channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

        string message = "Hello World!";
        var body = Encoding.UTF8.GetBytes(message);

        channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);
        Console.WriteLine(" [x] Sent {0}", message);
    }

    Console.WriteLine(" Press [enter] to exit.");
    Console.ReadLine();

Upvotes: 1

Views: 317

Answers (1)

Gabriele Santomaggio
Gabriele Santomaggio

Reputation: 22682

BrokerUnreachableException means that the client can't reach the server.

Check if the server is actually up and running, or if you have some firewall configuration.

There are several posts about BrokerUnreachableException, follow for example this thread about that

Upvotes: 1

Related Questions