magro / memcached-session-manager

A tomcat session manager that backups sessions in memcached and pulls them from there if asked for unknown sessions
Apache License 2.0
760 stars 346 forks source link

Tomcat7 sharing is not successful. #379

Open koulq opened 6 years ago

koulq commented 6 years ago

Hello, I am using tomcat7.0.81. After configuration, session sharing is not successful. Below are my configuration and jar packages.

qq 20180320195229 qq 20180320195350

The session stored in memcached is as follows. qq 20180320195617 The sessionId is always changing, and the background log shows no errors.

magro commented 6 years ago

Not all those jars should be in tomcat/lib, kryo related jars should be in WEB-INF/lib (which is automatically the case when you add the msm-kryo-serializer as maven dependency to your application) - for details see https://github.com/magro/memcached-session-manager/wiki/SetupAndConfiguration#add-memcached-session-manager-jars-to-tomcat and the following paragraph.

koulq commented 6 years ago

But I can use Tomcat6.

zhipingch commented 5 years ago

I have the same issue! The sessionId is always changing, and the tomcat log shows: Apr 22, 2019 6:29:36 PM de.javakaffee.web.msm.MemcachedSessionService changeSessionIdOnMemcachedFailover WARNING: Could not find session in local session map. java.lang.IllegalArgumentException: The given node id aa19-4f81-9668-dfadfa1bb08f is not part of this list [n1] at de.javakaffee.web.msm.NodeIdList.getNextNodeId(NodeIdList.java:60) at de.javakaffee.web.msm.MemcachedNodesManager.getNextAvailableNodeId(MemcachedNodesManager.java:359) at de.javakaffee.web.msm.MemcachedSessionService.loadBackupSession(MemcachedSessionService.java:885) at de.javakaffee.web.msm.MemcachedSessionService.changeSessionIdOnMemcachedFailover(MemcachedSessionService.java:861) at de.javakaffee.web.msm.RequestTrackingContextValve.changeRequestedSessionId(RequestTrackingContextValve.java:128) at de.javakaffee.web.msm.RequestTrackingContextValve.invoke(RequestTrackingContextValve.java:98) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:74

and nodeId="aa19-4f81-9668-dfadfa1bb08f", , I think maybe SessionIdFormat.extractMemcachedId() has some bugs?

final String nodeId = _sessionIdFormat.extractMemcachedId( sessionId ); @CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) / The dash was part of the jvmRoute / { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } }

zhipingch commented 5 years ago

Cloud you help me fix the bugs?