Я новичок в RabbitMQ.
Я пытался запустить пример кода оттуда учебник :
Код:
class Receive
{
public static void Main()
{
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);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (model, ea) =>
{
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
Console.WriteLine(" [x] Received {0}", message);
};
channel.BasicConsume(queue: "hello",
autoAck: true,
consumer: consumer);
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
}
}
}
I запустите код vs 2019 в этой строке:
using(var connection = factory.CreateConnection())
Я получаю сообщение об ошибке:
RabbitMQ.Client.Exceptions.BrokerUnreachableException: 'None of the specified endpoints were reachable'
ExtendedSocketException: No connection could be made because the target machine actively refused it. 127.0.0.1:5672
попытался перейти на другие порты:
var factory = new ConnectionFactory() { HostName = "localhost", Port = 8080 };
var factory = new ConnectionFactory() { HostName = "localhost", Port = 8081 };
var factory = new ConnectionFactory() { HostName = "localhost", Port = 5671 };
var factory = new ConnectionFactory() { HostName = "localhost", Port = 5673 };
...
включен от брандмауэра, и все еще получаю то же исключение