我从RabbitMQ教程中复制了以下代码,并做了些微改动:
_factory = new ConnectionFactory() {HostName = "10.1.1.110"};
_factory.UserName = "admin";
_factory.Password = "admin";
_connection = _factory.CreateConnection();
_channel = _connection.CreateModel();
_channel.ExchangeDeclare("hello-exchange", "topic");
_channel.QueueDeclare(queue: "hello",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
_channel.QueueBind("hello", "hello-exchange", "helloRoutingKey.#");
但是,当它运行到_factory.CreateConnection()时,我会遇到一些异常:
Exception thrown: 'System.ArgumentException' in RabbitMQ.Client.dll
Exception thrown: 'System.ArgumentException' in mscorlib.dll
Exception thrown: 'System.ArgumentException' in mscorlib.dll
Exception thrown: 'RabbitMQ.Client.Exceptions.ConnectFailureException' in RabbitMQ.Client.dll
Exception thrown: 'RabbitMQ.Client.Exceptions.ConnectFailureException' in RabbitMQ.Client.dll
但是连接似乎正常,因为我仍然可以发布和接收。但是过了一会儿,接收者将再次抛出这些异常,然后与RabbitMQ服务器断开连接,但是发送者仍然可以发送消息。谁能帮忙看看有什么问题吗?
我的ASP.NET版本是4.7.2,RabbitMQ.Client版本是5.1.0。我也尝试了5.0.1,但仍然会引发异常。