Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN

我越来越低于例外

异常: 使用身份验证机制 PLAIN 拒绝了 ACCESS _ REFUSED 登录。有关详细信息,请参阅代理日志文件。

Configuration: RabbitMQ 3.3.5 on windows

%APPDATA%\RabbitMQ\rabbit.config中的配置文件上 我已经按照 href = “ https://www.rabbitmq.com/access-control.html”rel = “ norefrer”> https://www.rabbitmq.com/access-control.html 做了以下更改

[{rabbit, [{loopback_users, []}]}].

我还尝试创建一个用户/pwd-test/test 似乎没有用。

尝试从 这个后的步骤。

其他配置详情如下:

Tomcat hosted Spring Application Context:

<!-- Rabbit MQ configuration Start -->
<!-- Connection Factory -->
<rabbit:connection-factory id="rabbitConnFactory" virtual-host="/" username="guest" password="guest" port="5672"/>


<!-- Spring AMQP Template -->
<rabbit:template id="rabbitTemplate" connection-factory="rabbitConnFactory" routing-key="ecl.down.queue" queue="ecl.down.queue" />


<!-- Spring AMQP Admin -->
<rabbit:admin id="admin" connection-factory="rabbitConnFactory"/>


<rabbit:queue id="ecl.down.queue" name="ecl.down.queue" />


<rabbit:direct-exchange name="ecl.down.exchange">
<rabbit:bindings>
<rabbit:binding key="ecl.down.key" queue="ecl.down.queue"/>
</rabbit:bindings>
</rabbit:direct-exchange>

在我的控制类

@Autowired
RmqMessageSender rmqMessageSender;


//Inside a method
rmqMessageSender.submitToECLDown(orderInSession.getOrderNo());

In My Message sender:

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Component("messageSender")
public class RmqMessageSender  {


@Autowired
AmqpTemplate                rabbitTemplate;


public void submitToRMQ(String orderId){
try{
rabbitTemplate.convertAndSend("Hello World");
} catch (Exception e){
LOGGER.error(e.getMessage());
}
}
}

上面的异常块给出下面的异常


异常: 使用身份验证机制 PLAIN 拒绝了 ACCESS _ REFUSED 登录。有关详细信息,请参阅代理日志文件。


错误日志

  =ERROR REPORT==== 7-Nov-2014::18:04:37 ===
closing AMQP connection <0.489.0> (10.1.XX.2XX:52298 -> 10.1.XX.2XX:5672):
{handshake_error,starting,0,
{amqp_error,access_refused,
"PLAIN login refused: user 'guest' can only connect via localhost",
'connection.start_ok'}}

请在 pom.xml 条目下找到

        <dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.3.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>

如果你有任何想法/建议,请告诉我

244173 次浏览

用户“ guest”只能通过 localhost 进行连接

从 RabbitMQ 3.3.x 开始就是这样。因此,您应该将客户端库升级到相同的版本,或者只是将 Spring AMQP 升级到最新版本(如果您使用依赖管理系统的话)。

Previous version of client used 127.0.0.1 as default value for the host option of ConnectionFactory.

我确信 Artem Bilan 解释的 给你可能是这个错误的原因之一:

Caused by: com.rabbitmq.client.AuthenticationFailureException:
ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN.
For details see the

但对我来说,解决方案是我登录到 rabbitMQ 管理页面(http://localhost:15672/#/users) ,使用默认的用户名和密码,即 guest/guest,然后添加了一个新用户,对于这个新用户,我启用了从虚拟主机访问它的权限,然后使用新的用户名和密码而不是默认的 guest,这样就清除了错误。

enter image description here

错误

ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

如果应用程序试图用于连接到 RabbitMQ 的凭据不正确或丢失,则可能发生。

当存储在 ASP.NET 应用程序的 web.config文件中的 RabbitMQ 凭据的密码值为 ""而不是实际的密码字符串值时,就会发生这种情况。

要允许客户远程访问,请编写以下代码

[{rabbit, [{loopback_users, []}]}].

to here

c:\Users\[your user name]\AppData\Roaming\RabbitMQ\rabbitmq.config

然后重新启动 rabbitmq 窗口服务(源 https://www.rabbitmq.com/access-control.html)

To complete @cpu-100 回答,

如果您不想启用/使用 web 界面,您可以使用下面的命令行创建一个新凭证,并在代码中使用它连接到 RabbitMQ。

$ rabbitmqctl add_user YOUR_USERNAME YOUR_PASSWORD
$ rabbitmqctl set_user_tags YOUR_USERNAME administrator
$ rabbitmqctl set_permissions -p / YOUR_USERNAME ".*" ".*" ".*"

新的解决方案:

节点模块无法正确处理密码中的 :。即使是 url 编码,就像它正常工作一样,它也不工作。

不要在密码中使用 URL 中的典型特殊字符!

就像下面这样: : . ? + %


Original, wrong answer:

The error message clearly complains about using PLAIN, it does not mean the crendentials are wrong, it means you must use encrypted data delivery (TLS) instead of plaintext.

Changing amqp:// in the connection string to amqps:// (note the s) solves this.

将 ConnectionFactory 或 Connection 主机名设置为 localhost

对我来说,解决方案很简单: 用户名区分大小写。不使用正确的大写也会导致错误。

只需添加登录密码就可以连接到 RabbitMq

 CachingConnectionFactory connectionFactory =
new CachingConnectionFactory("rabbit_host");


connectionFactory.setUsername("login");
connectionFactory.setPassword("password");

如果您使用的数字作为您的密码,也许您应该尝试改变您的密码使用字符串。

我可以登录使用 deltaqin: 000000在网站上,但有这个同时运行的程序。然后将密码更改为 deltaqn。而且成功了。

我做的正是“ grepit”做的。

但是我不得不对我的 Java 代码进行一些修改:

在生产者和接收者项目中,我修改了:

ConnectionFactory factory = new ConnectionFactory();
factory.setHost("your-host-ip");
factory.setUsername("username-you-created");
factory.setPassword("username-password");


        

这样做,您将连接一个特定的主机作为您创建的用户。 我没问题!

由于在 Spring boot application.properties 中密码(spring.rabbitmq.password = Rabbit)末尾有空白,所以我遇到了这个问题。希望这个清单能帮助有些人面对这个问题。

在 localhost 上,默认情况下使用 “ amqp://guest: guest@localhost: 5672”

因此,在一个远程或托管的 RabbitMQ 上

username: niceboy 密码: notnice 主持人: goxha.com 港口: 1597

那么你应该通过的 URI 将是

好男孩: notnice@goxha.com: 1597

遵循模板 amqp://user: pass@host: 10000

如果您有一个 vhost,您可以执行 amqp://user: pass@host: 10000/vhost,其中尾随的 vhost 将是您的 vhost 的名称

在我的例子中,由于错误地设置了密码(我试图使用5672,但是我系统中的实际密码是5676) ,我出现了这个错误。 也许这能帮助人们重新检查端口。

对于 C # 代码,我尝试了下面的代码,它的工作,也许这可以帮助有人这样张贴在这里。

场景-RabbitMQ 队列在局域网中的另一个系统上运行,但是我出现了同样的错误。

默认情况下存在一个“来宾”用户。但是你不能访问远程服务器的队列(rabbitMq)使用“客户”用户,所以你需要创建新的用户,这里我创建了“ tester001”用户访问远程服务器的队列数据。

ConnectionFactory factory = new ConnectionFactory();
factory.UserName = "tester001";
factory.Password = "testing";
factory.VirtualHost = "/";
factory.HostName = "192.168.1.101";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;

如果您尝试了所有这些问题的答案,但仍然得到“ ACCESS _ REFUSED-使用身份验证机制 PLAIN 拒绝登录”,也许您应该删除 rabbitmq 并使用更新的版本安装它。 新版本对我很有效。