{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-session/issues/256","labels_url":"https://api.github.com/repos/spring-projects/spring-session/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-session/issues/256/comments","events_url":"https://api.github.com/repos/spring-projects/spring-session/issues/256/events","html_url":"https://github.com/spring-projects/spring-session/issues/256","id":98780439,"number":256,"title":"Apache mod_jk with Spring-session","user":{"login":"eladh","id":1949539,"avatar_url":"https://avatars.githubusercontent.com/u/1949539?v=3","gravatar_id":"","url":"https://api.github.com/users/eladh","html_url":"https://github.com/eladh","followers_url":"https://api.github.com/users/eladh/followers","following_url":"https://api.github.com/users/eladh/following{/other_user}","gists_url":"https://api.github.com/users/eladh/gists{/gist_id}","starred_url":"https://api.github.com/users/eladh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eladh/subscriptions","organizations_url":"https://api.github.com/users/eladh/orgs","repos_url":"https://api.github.com/users/eladh/repos","events_url":"https://api.github.com/users/eladh/events{/privacy}","received_events_url":"https://api.github.com/users/eladh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-session/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"rwinch","id":362503,"avatar_url":"https://avatars.githubusercontent.com/u/362503?v=3","gravatar_id":"","url":"https://api.github.com/users/rwinch","html_url":"https://github.com/rwinch","followers_url":"https://api.github.com/users/rwinch/followers","following_url":"https://api.github.com/users/rwinch/following{/other_user}","gists_url":"https://api.github.com/users/rwinch/gists{/gist_id}","starred_url":"https://api.github.com/users/rwinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwinch/subscriptions","organizations_url":"https://api.github.com/users/rwinch/orgs","repos_url":"https://api.github.com/users/rwinch/repos","events_url":"https://api.github.com/users/rwinch/events{/privacy}","received_events_url":"https://api.github.com/users/rwinch/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-08-03T16:20:36Z","updated_at":"2015-08-04T13:34:16Z","closed_at":null,"body":"Hello :-) \r\n\r\nFirst , thanks for this great project.\r\n\r\nWe having some issues with our Apache mod_jk balancing : \r\nsetting a cluster of 2 servers : \r\n\r\n- Each server is  a Spring boot with Embedded tomcat container .\r\n- Sticky session configuration \r\n \r\nFor some reason when setting up the Spring session the client request are sent randomly to the cluster members.\r\n\r\nAlso we needed to create PearlHttpSessionStrategy to get the spring session id.\r\n\r\nwe set the JvmRoute properly and the mod_jk also configured as needed.\r\nwhen switching back from spring session things get to normal again.\r\n\r\nAFAIK - the apache balancing is based on the jvm route appended to the the JSESSIONID and in this case there is no such information for the apache balancer \r\n\r\nthe strange think here is that we only see SESSION = XXXX in the client browser cookie  resources.\r\nwhen switching back we see the original JSESSIONID = XXXX.\r\n\r\nThanks in advance,\r\nelad.\r\n\r\n\r\n```\r\n # USERTEST Node 1\r\nworker.pearlusertest1.port=8009\r\nworker.pearlusertest1.host=pearlapput1\r\nworker.pearlusertest1.type=ajp13\r\nworker.pearlusertest1.socket_keepalive=true\r\nworker.pearlusertest1.lbfactor=1\r\nworker.pearlusertest1.connection_pool_size=50\r\nworker.pearlusertest1.connect_timeout=5000\r\nworker.pearlusertest1.prepost_timeout=5000\r\n\r\n # USERTEST Node 2\r\nworker.pearlusertest2.port=8009\r\nworker.pearlusertest2.host=pearlapput2\r\nworker.pearlusertest2.type=ajp13\r\nworker.pearlusertest2.socket_keepalive=true\r\nworker.pearlusertest2.lbfactor=1\r\nworker.pearlusertest2.connection_pool_size=50\r\nworker.pearlusertest2.connect_timeout=5000\r\nworker.pearlusertest2.prepost_timeout=5000\r\n\r\n\r\n# Load-balancing behaviour\r\nworker.pearlusertestlb.type=lb\r\nworker.pearlusertestlb.balance_workers=pearlusertest1,pearlusertest2\r\nworker.pearlusertestlb.sticky_session=1\r\n```\r\n\r\n```\r\n@Bean\r\n\tpublic FilterRegistrationBean webSessionsFilter() {\r\n\t\tMap<String, ExpiringSession> sessions;\r\n\r\n\t\tif (env.acceptsProfiles(Profiles.SPRING_PROFILE_HAZELCAST)) {\r\n\t\t\tsessions = hazelcastConfiguration.getHazelcastInstance().getMap(SpringSessionHazelcastConfig.SPRING_SESSIONS);\r\n\t\t} else {\r\n\t\t\tsessions = Maps.newConcurrentMap();\r\n\t\t}\r\n\r\n\t\tSessionRepository<ExpiringSession> sessionRepository = new MapSessionRepository(sessions);\r\n\t\t((MapSessionRepository) sessionRepository).setDefaultMaxInactiveInterval(SESSION_TIMEOUT);\r\n\t\tSessionRepositoryFilter filter = new SessionRepositoryFilter<ExpiringSession>(sessionRepository);\r\n\t\tfilter.setHttpSessionStrategy(pearlHttpSessionStrategy);\r\n\r\n\t\tFilterRegistrationBean filterRegBean = new FilterRegistrationBean();\r\n\t\tfilterRegBean.setFilter(filter);\r\n\t\tfilterRegBean.setUrlPatterns(Lists.newArrayList(\"/*\"));\r\n\t\tfilterRegBean.setAsyncSupported(true);\r\n\t\tfilterRegBean.setOrder(0);\r\n\t\treturn filterRegBean;\r\n\t}\r\n\r\n```\r\n\r\n\r\n```\r\n@Service\r\n@Provider\r\npublic class PearlHttpSessionStrategy implements MultiHttpSessionStrategy,ContainerResponseFilter {\r\n\r\n    private final MultiHttpSessionStrategy delegate;\r\n\r\n    public PearlHttpSessionStrategy() {\r\n        delegate = new CookieHttpSessionStrategy();\r\n    }\r\n\r\n    @Override\r\n    public String getRequestedSessionId(HttpServletRequest request) {\r\n        return delegate.getRequestedSessionId(request);\r\n    }\r\n\r\n    @Override\r\n    public void onNewSession(Session session, HttpServletRequest request, HttpServletResponse response) {\r\n        delegate.onNewSession(session ,request ,response);\r\n    }\r\n\r\n    @Override\r\n    public void onInvalidateSession(HttpServletRequest request, HttpServletResponse response) {\r\n        delegate.onInvalidateSession(request ,response);\r\n    }\r\n\r\n    @Override\r\n    public HttpServletRequest wrapRequest(HttpServletRequest request, HttpServletResponse response) {\r\n        HttpServletRequest wrappedRequest = delegate.wrapRequest(request ,response);\r\n        SpringSessionRequestHolder.setRequestAttributes(wrappedRequest.getSession().getId());\r\n        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(wrappedRequest));\r\n        return wrappedRequest;\r\n    }\r\n\r\n    @Override\r\n    public HttpServletResponse wrapResponse(HttpServletRequest request, HttpServletResponse response) {\r\n        return delegate.wrapResponse(request ,response);\r\n    }\r\n\r\n    @Override\r\n    public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {\r\n        SpringSessionRequestHolder.resetRequestAttributes();\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-session/issues/comments/127613073","html_url":"https://github.com/spring-projects/spring-session/issues/256#issuecomment-127613073","issue_url":"https://api.github.com/repos/spring-projects/spring-session/issues/256","id":127613073,"user":{"login":"eladh","id":1949539,"avatar_url":"https://avatars.githubusercontent.com/u/1949539?v=3","gravatar_id":"","url":"https://api.github.com/users/eladh","html_url":"https://github.com/eladh","followers_url":"https://api.github.com/users/eladh/followers","following_url":"https://api.github.com/users/eladh/following{/other_user}","gists_url":"https://api.github.com/users/eladh/gists{/gist_id}","starred_url":"https://api.github.com/users/eladh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eladh/subscriptions","organizations_url":"https://api.github.com/users/eladh/orgs","repos_url":"https://api.github.com/users/eladh/repos","events_url":"https://api.github.com/users/eladh/events{/privacy}","received_events_url":"https://api.github.com/users/eladh/received_events","type":"User","site_admin":false},"created_at":"2015-08-04T13:34:15Z","updated_at":"2015-08-04T13:34:15Z","body":"Hi .\r\n\r\nafter further investigation we must have sticky session for the time being , the reason or the fault is in out client size - there are some ajax requests that not written well with promises or chain of requests .\r\nFrom tomcat docs : tomcat rewrites the session id to ensure that the next request will remain sticky (and not fall back to go to random nodes)\r\n\r\nand before spring session we got  = JSESSIONID=XXXXXX.[JvmRouteId] \r\n\r\n10x\r\nelad."}}