jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Session values are not shared to multiple instances in Persistent HTTP Sessions moudle of Google Cloud DataStore

Open ashraftalib opened this issue 6 months ago • 6 comments

Jetty version(s) Version 12.0.6

Jetty Environment server,http,sessions,ee8-deploy,ee8-jsp,session-store-gcloud

Java version/vendor Java 21 OS type/version Linux

Description Using docker file and enabling the persistence session in Google AppEngine with session-store-gcloud moudle for session values are not shared with another instance in Google AppEngine flex.

How to reproduce? I am using commands form the Dockerfile : https://github.com/jetty/jetty.docker/tree/master/eclipse-temurin/12.0/jdk21

Below is sample snippet of my docekrfile for adding the moudles: server,http,sessions,ee8-deploy,ee8-jsp, session-store-gcloud. GCP datastore session to deploy the war file as

WORKDIR $JETTY_BASE COPY docker-entrypoint.sh generate-jetty-start.sh / COPY ./sample.ini $JETTY_BASE/start.d/sample.ini COPY ./sample.properties $JETTY_BASE/webapps/sample.properties COPY ./sample.war $JETTY_BASE/webapps/sample.war COPY ./id-manager.xml $JETTY_HOME/etc/sessions/id-manager.xml

USER jetty EXPOSE 8080 ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["java","-jar","/usr/local/jetty/start.jar"]

sample.ini has all configurations for - ee8-deploy,ee8-jsp,session-store-gcloud as below

--modules=ee8-deploy --modules=ee8-jsp

--modules=sessions --module=session-store-gcloud

I am able to use Module for Persistent HTTP Sessions: Google Cloud Datastore Successfully. And GCloudSession entities are saved with the attributes as

Name/ID | accessed | attributes | contextPath | cookieSetTime | createTime | expiry | id | last Accessed | lastNode | lastSaved | maxInactive | vhost

I am running my service on two instances there may be chance to many instance (autoscaling mode). There is an issue of HTTP Sessions are not shared with another instance.

**Scenario: **

If suppose a user is opening a url link(page) and have not login or session in app. Initially there is no session of a user at that time app saves this page url in session and redirect to login the app with this session values on one instance after login there is user's session and that url value also so for opening this page it will redirect the user with same page and now this page opens in other instance but there is user's login session already(in gcp-datastore) and not able to open the url(page) and this page again asks the user to login. Even user has already login in on instance and saved all values in session.

Example suppose one instance: aef-default-206-7b0n have no session value then it will save the page link in session (gcp datastore on this node) and redirect to login and save all user's details in session (gcp datastore) on the node aef-default-206-7b0n and at same time there is a url in session, which has to be open the same page after login to app and it will redirect to that url(page) on any node if we have a persistence session. Now the url is opening in other instance: aef-default-206-7z0b and this instance page is showing there is no login session (Even there is already a persistence session through gcp data-store) and it again redirect the user to login the app. Even user has already login on the first instance. Why this session is not shared to other instance with updates the attributes for both nodes.?

This behaviour occurred sometime and sometimes it works fine and user able to open the url on second instance with shared session values.

Is there something is missing in my app configuration for session module to GCP datastore ? I want session should be shared and updated on both nodes(instances) so it should not come the login page if a user already login and saved session for any node.

Please help me what should I have to do?

ashraftalib avatar Jul 30 '24 11:07 ashraftalib