Closed cpemaratech closed 4 years ago
Hey, we are facing the exact same problem. Did you manage to get it working ? Please let us know. Thanks.
Yeah . I should have closed this issue long back.
@kumar-chandan-kc -
It's been a long time Memcached running smoothly in our Production.
I recalled it was a place in the application which was creating new session
. If you have not yet done try enabling SessionListener
and SessionAttributeListener
and see is session being created or destroyed by application unexpectedly ?
We have deployed latest Memcached in our RedHat Linux Box.
At client side In our spring boot application we are using spymemcached-2.12.3.jar , memcached-2.3.0.jar ,tc8-2.3.0.jar
We have 2 app server behind load balancer and below is our client configuration -
memcached.session.storage.enabled=true
memcached.server.hostname=XX.XX.XX.XX
memcached.server.port=11211
memcached.server.user=XXXXXX
memcached.server.password=XXXXXX
memcached.uri.ignore.pattern=ico|png|gif|jpg|css|js|bmp|jpeg
memcached.session.sticky=false
memcached.session.backup.async=false
memcached.session.backup.thread.count=10000
memcached.session.locking.mode=auto
Issue - When we logged in to application we are able to successfully login and see logged in user profile data. However upon subsequent navigating to other pages , our application gets logout.
We have memcached-session-manager log , spring security log , and memecached server log for your review. app-log-without-memcached.txt memcached-server-log.txt siteapp1.txt siteapp2.txt
What I noticed -
Without memcached if we run on single instance and when navigate page , then in Chrome -> Developer Tool -> Application -> Cookie , we are seeing only single JSESSION ID across many request
With memcached enabled if we run on single instance and when navigate page , then in Chrome -> Developer Tool -> Application -> Cookie , we are seeing multiple JSESSIONID frequently getting changed.
Point#2 can be validated by verifying application log where as
MemcachedBackupSessionManager
create new session Id many times.There is a log from spring security which observer no presence of session and causing application to logout as it doesn't find security context.
2018-11-25 18:40:57.163 DEBUG 6507 --- [http-nio-8080-exec-10] o.s.s.w.session.SessionManagementFilter : Requested session ID 10104B61478B5087782364960D3BABD3 is invalid.
2018-11-25 13:49:17.249 DEBUG 8440 --- [http-nio-8080-exec-10] w.c.HttpSessionSecurityContextRepository : Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: 'org.springframework.security.core.context.SecurityContextImpl@bae7b640: Authentication: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@bae7b640: Principal: org.broadleafcommerce.profile.core.service.CustomerUserDetails@fef8ae5c: Username: a.1@cp.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@21a2c: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: D4E690E38691C5CE49A14F975459F97B; Granted Authorities: ROLE_USER'
Do you have any suggestions based on this information ?