2

I am trying to store tomcat session in redis server using Redisson . I have followed the steps mentioned in this link ( Tomcat 8 Session Replication with Redis ). I am using a redisson.conf file instead of redisson.yaml

singleServerConfig:
    idleConnectionTimeout: 10000
    connectTimeout: 10000
    timeout: 3000
    retryAttempts: 3
    retryInterval: 1500
    password: null
    subscriptionsPerConnection: 5
    clientName: null
    address: "redis://127.0.0.1:6379"
    subscriptionConnectionMinimumIdleSize: 1
    subscriptionConnectionPoolSize: 50
    connectionMinimumIdleSize: 10
    connectionPoolSize: 64
    database: 0
    dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.SerializationCodec> {}

And Session Manager in context.xml is as follows :

<Manager className="org.redisson.tomcat.RedissonSessionManager"
          configPath="${catalina.base}/conf/redisson.conf" readMode="REDIS" updateMode="DEFAULT" broadcastSessionEvents="true" keyPrefix=""/>

I am getting the following error while loading the login page . It also stops the redis server . Any suggestion to solve the issue would be helpful . Thank you .

org.redisson.tomcat.RedissonSessionManager findSession
SEVERE: Can't read session object by id: 34AE84972BC40CFB6C9C1B58CCDF37FE
org.redisson.client.WriteRedisConnectionException: Unable to write command into connection! Node source: NodeSource [slot=0, addr=null, redisClient=null, redirect=null, entry=null], connection: RedisConnection@1145017718 [redisClient=[addr=redis://127.0.0.1:6379], channel=[id: 0xdc07292a, L:0.0.0.0/0.0.0.0:53157], currentCommand=null], command: (HMGET), params: [redisson:tomcat_session:34AE84972BC40CFB6C9C1B58CCDF37FE, PooledUnsafeDirectByteBuf(ridx: 0, widx: 24, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 13, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 26, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 17, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 24, cap: 256), SimpleLeakAwareByteBuf(PooledUnsafeDirectByteBuf(ridx: 0, widx: 27, cap: 256)), PooledUnsafeDirectByteBuf(ridx: 0, widx: 15, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 16, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 20, cap: 256)] after 3 retry attempts
    at org.redisson.command.RedisExecutor.checkWriteFuture(RedisExecutor.java:280)
    at org.redisson.command.RedisExecutor.access$100(RedisExecutor.java:60)
    at org.redisson.command.RedisExecutor$1.operationComplete(RedisExecutor.java:161)
    at org.redisson.command.RedisExecutor$1.operationComplete(RedisExecutor.java:158)
    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
    at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552)
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
    at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
    at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609)
    at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.safeSetFailure(AbstractChannel.java:1017)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:878)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1367)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764)
    at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.channel.StacklessClosedChannelException
    at io.netty.channel.AbstractChannel$AbstractUnsafe.write(Object, ChannelPromise)(Unknown Source)    

org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketException: Connection reset by peer: socket write error; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset by peer: socket write error
                at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:47) ~[spring-data-redis-1.6.2.RELEASE.jar:1.6.2.RELEASE]
        
        Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
            at redis.clients.util.Pool.getResource(Pool.java:42) ~[jedis-2.5.1.jar:?]
            at redis.clients.jedis.JedisPool.getResource(JedisPool.java:84) ~[jedis-2.5.1.jar:?]
            at redis.clients.jedis.JedisPool.getResource(JedisPool.java:10) ~[jedis-2.5.1.jar:?]
            at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:155) ~[spring-data-redis-1.6.2.RELEASE.jar:1.6.2.RELEASE]
            ... 19 more
        Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
Bala
  • 21
  • 3

1 Answers1

0

don't use readMode="REDIS"... readMode="MEMORY" works better

In MEMORY mode, the information is stored in tomcat and replicated in the same way to redis. When using spring it generates a conflict to generate the connection only pointing to REDIS. It uses the Redisson-all and Redisson-tomcatXX libraries and not Jedis libs.

ref https://redisson.org/articles/redis-based-tomcat-session-management.html