I have the following Spring Session code:
@Bean
public LettuceConnectionFactory connectionFactory() {
String hostName = AcmeProperty.getProperty("spring.redis.host", "localhost");
int port = Integer.parseInt(AcmeProperty.getProperty("spring.redis.port", "6379"));
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(hostName, port);
return new LettuceConnectionFactory(redisStandaloneConfiguration);
}
It works just fine with the following settings when I'm running redis locally:
spring.redis.host=localhost
spring.redis.port=6379
However when I use Azure Cache for Redis with the following setting:
spring.redis.host=acmedev.redis.cache.windows.net
spring.redis.port=6380
I get this warning and the app hangs:
WARN (org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration:166) || - Unable to obtain SessionCookieConfig: Section 4.4 of the Servlet 3.0 specification does not permit this method to be called from a ServletContextListener that was not defined in web.xml, a web-fragment.xml file nor annotated with @WebListener
What do I need to change to get this to work with Azure Cache for Redis?
I've tried this code, but the same thing happens:
@Bean
public JedisConnectionFactory connectionFactory() {
String hostName = AcmeProperty.getProperty("spring.redis.host", "localhost");
int port = Integer.parseInt(AcmeProperty.getProperty("spring.redis.port", "6379"));
String password = AcmeProperty.getProperty("spring.redis.password");
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLParameters sslParameters = new SSLParameters();
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
sslParameters.setProtocols(new String[]{"TLSv1.2"});
String uriStr = String.format("rediss://%s:%s", hostName, port);
URI uri = URI.create(uriStr);
JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, null);
shardInfo.setPassword(password);
return new JedisConnectionFactory(shardInfo);
}