您好,在按照其网站上的教程操作后,这是下面的代码,在连接RabbitMQ服务器时遇到问题。
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();
答案 0 :(得分:1)
BrokerUnreachableException
表示客户端无法访问服务器。
检查服务器是否真正启动并正在运行,或者是否具有防火墙配置。
关于BrokerUnreachableException
的几篇文章,例如this thread的相关文章