2

下面是我用来创建rabbitmq连接的java代码,用于在elasticsearch中创建索引,这会引发异常。当我使用它factory.setHost("localhost");而不是factory.setHost("192.168.xx.xxx");它工作正常但是当我使用 IP 时它会导致我低于异常

com.rabbitmq.client.PossibleAuthenticationFailureException: 可能是认证失败引起的异常

下面是我用于连接的java代码 -

    factory = new ConnectionFactory();
    String value = null;
    if(serviceConfiguration == null)
        throw new NullObjectFoundException("ServiceConfiguration object is not set");
        factory.setUsername("guest");
        factory.setPassword("guest");
        factory.setVirtualHost("/");
        factory.setHost("192.168.xx.xxx");
        factory.setPort(Integer.parseInt( 5672));

    try{
        conn = factory.newConnection();
        return conn;
    }   // try
    catch(Exception e){
        System.out.println(e);
    }   // catch
4

0 回答 0