Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录 [英] Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN

查看:214
本文介绍了Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下异常

<块引用>

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - 使用 PLAIN 身份验证机制拒绝登录.有关详细信息,请参阅代理日志文件.

配置:Windows 上的 RabbitMQ 3.3.5

%APPDATA%\RabbitMQ\rabbit.config 中的配置文件我根据 https://www.rabbitmq.com/access-control.html

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

我也尝试过创建用户/密码 - 测试/测试似乎不起作用.

尝试了这篇帖子中的步骤.

其他配置详情如下:

Tomcat 托管的 Spring 应用程序上下文:

<!-- 连接工厂--><rabbit:connection-factory id="rabbitConnFactory" virtual-host="/" username="guest" password="guest" port="5672"/><!-- Spring AMQP 模板--><rabbit:template id="rabbitTemplate" connection-factory="rabbitConnFactory" routing-key="ecl.down.queue" queue="ecl.down.queue"/><!-- Spring AMQP 管理员--><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:binding key="ecl.down.key" queue="ecl.down.queue"/></rabbit:bindings></rabbit:direct-exchange>

在我的控制器类中

@AutowiredrmqMessageSender rmqMessageSender;//方法内部rmqMessageSender.submitToECLDown(orderInSession.getOrderNo());

在我的消息发件人中:

import org.springframework.amqp.core.AmqpTemplate;导入 org.springframework.beans.factory.annotation.Autowired;导入 org.springframework.stereotype.Component;@Component("messageSender")公共类 RmqMessageSender {@自动连线AmqpTemplate rabbitTemplate;public void submitToRMQ(String orderId){尝试{rabbitTemplate.convertAndSend("Hello World");} 捕获(异常 e){LOGGER.error(e.getMessage());}}}

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

<小时><块引用>

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - 使用 PLAIN 身份验证机制拒绝登录.有关详细信息,请参阅代理日志文件.

<小时>

错误日志

 =错误报告==== 7-Nov-2014::18:04:37 ===关闭 AMQP 连接 <0.489.0>(10.1.XX.2XX:52298 -> 10.1.XX.2XX:5672):{handshake_error,starting,0,{amqp_error,access_refused,PLAIN 登录被拒绝:用户‘guest’只能通过本地主机连接",'connection.start_ok'}}

请在 pom.xml 条目下方找到

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

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

解决方案

我确定 Artem Bilan 在这里解释了什么可能是此错误的原因之一:

<块引用>

引起:com.rabbitmq.client.AuthenticationFailureException:ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录.有关详细信息,请参阅

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

I am getting below exception

org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

Configuration: RabbitMQ 3.3.5 on windows

On Config file in %APPDATA%\RabbitMQ\rabbit.config I have done below change as per https://www.rabbitmq.com/access-control.html

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

I also tried creating a user/pwd - test/test doesn't seem to make it work.

Tried the Steps from this post.

Other Configuration Details are as below:

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>

In my Controller Class

@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());
        }
    }       
}

Above exception Block gives below Exception


org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.


Error Log

  =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'}}

Pls find below the pom.xml entry

        <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>

Please let me know if you have any thoughts/suggestions

解决方案

I am sure what Artem Bilan has explained here might be one of the reasons for this error:

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

but the solution for me was that I logged in to rabbitMQ admin page (http://localhost:15672/#/users) with the default user name and password which is guest/guest then added a new user and for that new user I enabled the permission to access it from virtual host and then used the new user name and password instead of default guest and that cleared the error.

这篇关于Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆