I try to run the samples, but I always get the exception below. How do I fix the problem? Do I need to change some versions?
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: ERR Unsupported CONFIG parameter: notify-keyspace-events; nested exception is redis.clien
ts.jedis.exceptions.JedisDataException: ERR Unsupported CONFIG parameter: notify-keyspace-events
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:44)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:36)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195)
at org.springframework.data.redis.connection.jedis.JedisConnection.setConfig(JedisConnection.java:618)
at org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.afterProp
ertiesSet(RedisHttpSessionConfiguration.java:170)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
... 22 more
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Unsupported CONFIG parameter: notify-keyspace-events
at redis.clients.jedis.Protocol.processError(Protocol.java:113)
at redis.clients.jedis.Protocol.process(Protocol.java:138)
at redis.clients.jedis.Protocol.read(Protocol.java:192)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:282)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:181)
at redis.clients.jedis.Jedis.configSet(Jedis.java:2480)
at org.springframework.data.redis.connection.jedis.JedisConnection.setConfig(JedisConnection.java:616)
... 25 more
Thank you for your feedback.
@EnableRedisHttpSession requires Redis 2.8.0+ I have added #115 to document this.
The reasoning is that the keyspace notifications are used to ensure that the SessionDestroyedEvent is fired. This is especially important if you are using Spring Session with WebSocket support.
If you are not using Spring Session with WebSocket support, then you can use a configuration similar to the following:
@Configuration
@EnableScheduling
public class RedisHttpSessionConfiguration {
// set to some value i.e. @Value("${spring.session.inactive}")
private Integer maxInactiveIntervalInSeconds;
@Bean
public RedisTemplate<String,ExpiringSession> sessionRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, ExpiringSession> template = new RedisTemplate<String, ExpiringSession>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(connectionFactory);
return template;
}
@Bean
public RedisOperationsSessionRepository sessionRepository(RedisTemplate<String, ExpiringSession> sessionRedisTemplate) {
RedisOperationsSessionRepository sessionRepository = new RedisOperationsSessionRepository(sessionRedisTemplate);
sessionRepository.setDefaultMaxInactiveInterval(maxInactiveIntervalInSeconds);
return sessionRepository;
}
@Bean
public <S extends ExpiringSession> SessionRepositoryFilter<? extends ExpiringSession> springSessionRepositoryFilter(SessionRepository<S> sessionRepository) {
SessionRepositoryFilter<S> sessionRepositoryFilter = new SessionRepositoryFilter<S>(sessionRepository);
return sessionRepositoryFilter;
}
}
@rwinch Please re-open. The problem is that embedded-redis bundles an older Redis version 2.6.
I have create a GitHub issue for that project: https://github.com/kstyrc/embedded-redis/issues/23
Thanks for looking into this @ghillert I have reopened the issue
Thanks to a PR from @domdorn this should now be resolved in master!
Sorry, but after I added 1.0.1-BUILD_SNAPSHOT dependency, I also got that error, so that fix does not resolve the bug.
@szabobar Let's track this issue further on #174
@szabobar I guess you're using Windows (as myself).
The embedded-redis:0.4 contains Redis 2.8 for Linux and Mac, but only version 2.6 for Windows. You have to patch the embedded-redis artifact or define an external path to your lokal Redis 2.8 executable.
@t4gedieb Thanks for the response. Can you respond to @kstyrc on kstyrc/embedded-redis#23 so that we can get the Windows version updated too?
add following bean in HttpSessionConfig
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}
Most helpful comment
add following bean in HttpSessionConfig
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}