1

I have an AWS "Classic Load Balancer" that relays the traffic and for 3 EC2 instances. On these EC2 instances (it's simple Linux machines) I have a GlassFish 4.1 running and listening to port 80.

When calling the URL for a single server, everything is fine (works as it is supposed to) but when the traffic is relayed by the Load Balancer, the request to the application server has no cookies.

I checked the balancer's "Enable load balancer generated cookie stickiness" option and also tried "Enable application generated cookie stickiness". Both times the balancer chooses a target server for the first request and uses relays all subsequent requests to the same server - but omits the cookies.

For example
After the login I have these cookies:

AWSELB      DD17B9....
JSESSIONID  8f22ce....
mnzkks      1869:1000:34....

When I click on any link on the page, I see that my browser includes the new cookies in the request:

GET /mypage/detail HTTP/1.1
Host: my.page.com
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 OPR/45.0.2552.888
Referer: https://my.page.com/dashboard
Cookie: JSESSIONID=8f22ce ...;
        AWSELB= DD17B9....; 
        mnzkks=1869:1000:345..

In a filter of my application I print out all the cookie names and check for the "mnzkks". If I can't find any cookie it prints no cookie :)

When using the server's original URL it prints

AWSELB
JSESSIONID
mnzkks

When using the URL of the balancer it always prints no cookie, even though the browser includes all 3 cookies in the request

who ate my cookies?

GameDroids
  • 113
  • 1
  • 5
  • I did a bit of searching to see if I could help answer this, but I can't find any documentation. Since no-one here can answer perhaps you should try the AWS forums? If you work it out please answer your own question, it's interesting and could help others. – Tim Jul 04 '17 at 19:24
  • Does your `Set-Cookie` response have a trailing semicolon? If so, [these AWS docs](http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html) suggest that that may be one of the issues: "If you have a trailing semicolon in the Set-Cookie field of an application cookie, the load balancer ignores the cookie." – Castaglia Jul 14 '17 at 02:49
  • After all this time, I wonder if and how you solved this issue, because I am having the exact same problem. – Leonardo Apr 10 '20 at 06:03
  • I am sorry, but I never found out what the problem was. I tried copying the configurations of a similar setup but it still didn't work so I had to change my strategy and setup a REST environment (using AWS lambdas) where I didn't rely on cookies. But I sure hope you will find a solution and maybe share it here? – GameDroids Apr 10 '20 at 06:36

0 Answers0