在 vertx 中使用身份验证的 Redis pubsub
Redis pubsub with authentication in vertx
我正在尝试按如下方式使用 redis pubsub chanel vertex,但我不断收到
NOAUTH Authentication required
以下是示例代码片段:我在redis.conf中配置了redis密码
vertx.eventBus().<JsonObject>consumer(VERTX_EVENTBUS_PREFIX + ASYNC_RESPONSE_CHANNEL, message -> {
log.debug("Vertx event bus consumer invoked");
});
}).exceptionHandler(t -> {
log.error("Exception thrown from vertx event bus consumer", t);
});
// Subscribe to the redis async response channel
redis.subscribe( ASYNC_RESPONSE_CHANNEL, res -> {
if (res.failed()) {
log.error("Failed to subscribe to the async response channel. " + res.cause().getMessage());
}
if(res.succeeded()) {
log.debug("Subscribed to channel");
}
}).auth("redispasswd", null);
在订阅时设置授权是错误的。它需要在 RedisOptions 对象中设置,并且需要在初始化时传递给 RedisClient。
RedisOptions redisCfg = new RedisOptions().setHost(redisHost).setPort(redisPort).setAuth(redisPassword);
RedisClient redis = RedisClient.create(vertx, redisCfg)
我正在尝试按如下方式使用 redis pubsub chanel vertex,但我不断收到
NOAUTH Authentication required
以下是示例代码片段:我在redis.conf中配置了redis密码
vertx.eventBus().<JsonObject>consumer(VERTX_EVENTBUS_PREFIX + ASYNC_RESPONSE_CHANNEL, message -> {
log.debug("Vertx event bus consumer invoked");
});
}).exceptionHandler(t -> {
log.error("Exception thrown from vertx event bus consumer", t);
});
// Subscribe to the redis async response channel
redis.subscribe( ASYNC_RESPONSE_CHANNEL, res -> {
if (res.failed()) {
log.error("Failed to subscribe to the async response channel. " + res.cause().getMessage());
}
if(res.succeeded()) {
log.debug("Subscribed to channel");
}
}).auth("redispasswd", null);
在订阅时设置授权是错误的。它需要在 RedisOptions 对象中设置,并且需要在初始化时传递给 RedisClient。
RedisOptions redisCfg = new RedisOptions().setHost(redisHost).setPort(redisPort).setAuth(redisPassword);
RedisClient redis = RedisClient.create(vertx, redisCfg)