Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录

2024-03-25

我遇到以下异常

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 https://www.rabbitmq.com/access-control.html

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

我还尝试创建用户/密码 - 测试/测试似乎不起作用。

尝试了以下步骤this https://stackoverflow.com/questions/23784080/rabbitmq-guest-login-failed post.

其他配置详情如下:

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

<!-- 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());

在我的消息发件人中:

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

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


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


错误日志

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

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


我确信 Artem Bilan 已经解释过了here https://stackoverflow.com/a/26820152/2947502可能是此错误的原因之一:

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录 的相关文章

随机推荐