request.getSession(false) returning null though active session available

1,011 views
Skip to first unread message

Naresh Pokuri

unread,
Nov 13, 2015, 9:50:25 AM11/13/15
to Google App Engine

I am testing my application on Google App Engine local devserver. And I see once user session timeout and logs-in again, for few request that logged in session worked. All of a sudden for few request new session created though active session sent in request headers.


working session request and response headers:

GET /_ah/api/havasay/v1/secured/search/tickets?type=ticket&criteria=organizationId:11d7e348-3559-4357-81a5-9b12268aeaac;channelId:2c17ac87-ff49-44c2-b91d-d35e72ccfe57,047a8141-e152-4a1c-b56c-3bb6310a4ebb;status:pending,reopened&offset=0&limit=20 HTTP/1.1

Host: local.havasay.com:8080

Accept: application/json, text/plain, */*

Accept-Encoding: gzip, deflate, sdch

Accept-Language: en-US,en;q=0.8

Cookie: JSESSIONID=11imty7x4cq58

orgKey: SAMS-00001

Referer: http://local.havasay.com:8080/home

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

X-DevTools-Emulate-Network-Conditions-Client-Id: 3E584D9A-0213-448C-9020-A407CA69883F

x-hs-salt: f93982f0d7b9c186b6d456abe7476fa97d749aa8fa9d94d712c51688e2dad8fd

X-Requested-With: XMLHttpRequest




HTTP/1.1 200 OK

Cache-Control: no-cache, no-store, must-revalidate

Content-Length: 146

Content-Type: application/json; charset=UTF-8

Date: Fri, 13 Nov 2015 08:23:43 GMT

Expires: 0

Pragma: no-cache

server: Development/1.0

Server: Jetty(6.1.x)

x-frame-options: DENY


New session created request and response headers:


POST /_ah/api/havasay/v1/secured/resource/users HTTP/1.1



Host: local.havasay.com:8080

Accept: application/json, text/plain, */*

Accept-Encoding: gzip, deflate

Accept-Language: en-US,en;q=0.8

Content-Type: application/json;charset=UTF-8

Cookie: JSESSIONID=11imty7x4cq58

orgKey: SAMS-00001

Origin: http://local.havasay.com:8080

Referer: http://local.havasay.com:8080/home

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

X-DevTools-Emulate-Network-Conditions-Client-Id: 3E584D9A-0213-448C-9020-A407CA69883F

x-hs-salt: f93982f0d7b9c186b6d456abe7476fa97d749aa8fa9d94d712c51688e2dad8fd

X-Requested-With: XMLHttpRequest




HTTP/1.1 200 OK

Access-Control-Allow-Credentials: true

Access-Control-Allow-Origin: http://local.havasay.com:8080

Cache-Control: no-cache, no-store, must-revalidate

Content-Length: 690

Content-Type: application/json; charset=UTF-8

Date: Fri, 13 Nov 2015 08:23:46 GMT

Expires: Fri, 13 Nov 2015 08:23:46 GMT

Pragma: no-cache

server: Development/1.0

Server: Jetty(6.1.x)

set-cookie: JSESSIONID=o9gl01qab596;Path=/

x-frame-options: DENY


And in my servlet filter I have code like this


String requestedSessionId = request.getRequestedSessionId();
        boolean requestedSessionIdFromCookie = request.isRequestedSessionIdFromCookie();
        LOGGER.info("Requested Session ID from cookie: "+requestedSessionIdFromCookie);
        LOGGER.info("Requested Session ID: "+requestedSessionId);
        HttpSession session = request.getSession(false);
        if(session == null){
            session = request.getSession(true);
        }
        LOGGER.info("Is Session New: "+session.isNew());
        LOGGER.info("Session ID: "+session.getId());


For above code log is as below

[INFO] INFO: Requested Session ID from cookie: true
[INFO] INFO: Requested Session ID: 11imty7x4cq58
[INFO] INFO: Is Session New: true
[INFO] INFO: Session ID: o9gl01qab596


I am not able to track what causes the issue? Is it problem with GAE? I am trying to find the root cause for last two days.. still no clue. Please help me

Nick (Cloud Platform Support)

unread,
Nov 13, 2015, 3:05:15 PM11/13/15
to Google App Engine
Hey Naresh,

A post like this should be sent to Stack Overflow. The forum you've posted to (Google Groups - App Engine) isn't meant for specific-issue one-on-one technical support, and so this post is off-topic.

Posting to Stack Overflow not only ensures that you won't get a response like this one, but also puts you in contact with a much larger group of developers who are possibly able to help. We monitor Stack Overflow actively, so there's no worry that you won't find any help.

Nick (Cloud Platform Support)

unread,
Nov 17, 2015, 9:49:11 AM11/17/15
to Google App Engine
Hey Naresh,

Have you managed to create a post on Stack Overflow? Feel free to link it here, as I'll be happy to help out with it over there! 


On Friday, November 13, 2015 at 9:50:25 AM UTC-5, Naresh Pokuri wrote:
Reply all
Reply to author
Forward
0 new messages