ERR unknown command 'CONFIG' when using Secured Redis
See original GitHub issueRedis security recommends disabling the CONFIG command so that remote users cannot reconfigure an instance. The RedisHttpSessionConfiguration requires access to this during its initialization. Hosted Redis services, like AWS ElastiCache disable this command by default, with no option to re-enable it.
Issue Analytics
- State:
- Created 9 years ago
- Comments:27 (15 by maintainers)
Top Results From Across the Web
ERR unknown command `CONFIG when trying to set dir
I'm trying to run the following redis-cli --raw -a '<password censored>' 'CONFIG SET dir /var/www/html'. However I keep getting: ERR unknown ...
Read more >Managed Redis configuration - DigitalOcean
when accessing redis via redlii there are no config variables available. e.g. > config get * (error) ERR unknown command `config`, with args ......
Read more >Why Is "ERR unknown command" Displayed When I Access a ...
Why Is "ERR unknown command" Displayed When I Access a DCS Redis Instance Through a Redis Client? ... The possible causes are as...
Read more >Azure/AWS: Take into account CONFIG command may not work
Trying to open the status page will throw this (at least running Predis): Predis\Response\ServerException: ERR unknown command `CONFIG`, ...
Read more >ERR unknown command 'CONFIG' when using Secured Redis
ERR unknown command 'CONFIG' when using Secured Redis ... 这段代码在执行到第一个判断就跳出,不在进行连接配置。解决此问题。 ... 可以设置session过期 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think it should be enabled by default, but fail gracefully with a warning. This would allow the same configuration to be used between dev and prod, where dev would JustWork™ and prod would require some manual intervention (which would be obvious from the warning).
I was able to work around the problem by subclassing the
RedisHttpSessionConfigurationwith an implementation that disables the keyspace notifications initializer, and bringing it in through normal configuration means:For posterity, here are the steps for enabling the keyspace notifications on AWS:
Log into the AWS console and choose the ElastiCache service
Choose the Cache Parameter Groups and click Create Parameter Group
Give the new group and name and description and click Create
With the new parameter group created, select it and click Edit Parameters
Page through the parameters until you find notify-keyspace-events and enter "eA" in the Value field and click Save Changes
Choose Cache Clusters from the context navigation and create a new Redis cache cluster
When specifying your cluster detail, choose the newly created parameter group
Thanks for the report @danveloper! This indeed seems to be a bug with the
RedisHttpSessionConfigurationand thus the@EnableRedisHttpSessionannotation.UPDATE Fixing in 1.0.1
As of Spring Session 1.0.1 this can be disabled by exposing
ConfigureRedisAction.NO_OPas a bean.An XML Configuration example
A Java Configuration example
Fixing the Issue
I’m debating what the best approach to fixing this would be though and wondering what your thoughts were @danveloper.
There is certainly a need for a fix, so I’m not debating that we need to fix something. However, I like the fact that it updates the Redis configuration by default for two reasons:
SessionDestroyedEventto be fired to clean up resources. In particular, this is important for WebSocket applications to ensure open WebSockets are closed when the HttpSession expires.My initial thoughts on how we should update the configuration is:
RedisHttpSessionConfigurationshould by default update the Redis configuration only if Spring WebSocket support is enabled.RedisHttpSessionConfigurationshould allow disabling updating the Redis configurationRedisHttpSessionConfigurationshould by default try to subscribe to keyspace notifications only if Spring WebSocket support is enabled. This will help increase performance for applications simply using Spring Session forHttpSessionwhich typically does not need to receive theSessionDestroyedEventRedisHttpSessionConfigurationshould allow explicitly configuring if the application should subscribe to keyspace notificationsWorkaround
In the meantime, a workaround is to remove
@EnableRedisHttpSessionfrom your configuration and then include a configuration with a fix. For example:If you are not using the
SessionDestroyedEventyou can also disable subscribing to the notifications which should improve performance. For example: