我有一個在EC2的tomcat實例中運行的web應用程序,我不能在我的生活中使用粘性會話在負載平衡器上工作。我已經遵循了http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html中的所有步驟,嘗試使用基於應用程序(使用JSESSIONID cookie)和基於時間(使用86400秒)的方法,但是無論如何,它根本不起作用。同一個用戶不斷在所有不同的節點上彈跳。每當他們點擊網頁上的新鏈接時,它都會將其彈回到主屏幕以再次登錄。無法在AWS中使用粘性會話?
我不知道爲什麼它不起作用。我也不太瞭解這個東西(嘿,直到2個小時前,我甚至不知道'粘滯會話'是什麼意思 - 不,我不能讓別人去做),所以我'我不確定從哪裏開始調試它。
編輯:看着我的cookies ..看來,AWSELB cookie不斷被刪除和重寫每次我加載網站,而不是像它應該堅持。
編輯2:我的負載均衡器的XML配置:
{
"LoadBalancerDescriptions": [
{
"Subnets": [
"subnet-5c83aa39",
"subnet-6a778830",
"subnet-c41cdde8"
],
"CanonicalHostedZoneNameID": "Z35SXDOTRQ7X7K",
"CanonicalHostedZoneName": "<ELB_NAME>-<redacted>.us-east-1.elb.amazonaws.com",
"ListenerDescriptions": [
{
"Listener": {
"InstancePort": 5432,
"LoadBalancerPort": 5432,
"Protocol": "TCP",
"InstanceProtocol": "TCP"
},
"PolicyNames": []
},
{
"Listener": {
"InstancePort": 8888,
"LoadBalancerPort": 8888,
"Protocol": "HTTP",
"InstanceProtocol": "HTTP"
},
"PolicyNames": [
"AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500995555135"
]
}
],
"HealthCheck": {
"HealthyThreshold": 2,
"Interval": 10,
"Target": "HTTP:44554/",
"Timeout": 8,
"UnhealthyThreshold": 4
},
"VPCId": "vpc-721bec0b",
"BackendServerDescriptions": [],
"Instances": [
{
"InstanceId": "i-0ca9c244ed930d58f"
},
{
"InstanceId": "i-0cf47dc916f3f3443"
},
{
"InstanceId": "i-09ce2f24abc50259f"
}
],
"DNSName": "<ELB_NAME>-<redacted>.us-east-1.elb.amazonaws.com",
"SecurityGroups": [
"sg-f5ff638b"
],
"Policies": {
"LBCookieStickinessPolicies": [
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500564994754",
"CookieExpirationPeriod": 86400
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500565103581",
"CookieExpirationPeriod": 0
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500566463445",
"CookieExpirationPeriod": 28800
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500566440580",
"CookieExpirationPeriod": 0
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500476922828",
"CookieExpirationPeriod": 86400
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500481383343",
"CookieExpirationPeriod": 86400
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500479370743",
"CookieExpirationPeriod": 86400
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500475843862",
"CookieExpirationPeriod": 86400
},
{
"PolicyName": "AWSConsole-LBCookieStickinessPolicy-<ELB_NAME>-1500995555135",
"CookieExpirationPeriod": 86400
}
],
"AppCookieStickinessPolicies": [
{
"PolicyName": "AWSConsole-AppCookieStickinessPolicy-<ELB_NAME>-1500477157435",
"CookieName": "JSESSIONID"
},
{
"PolicyName": "AWSConsole-AppCookieStickinessPolicy-<ELB_NAME>-1500472642494",
"CookieName": "JSESSIONID"
},
{
"PolicyName": "AWSConsole-AppCookieStickinessPolicy-<ELB_NAME>-1500473344752",
"CookieName": "JSESSIONID"
},
{
"PolicyName": "AWSConsole-AppCookieStickinessPolicy-<ELB_NAME>-1500473227851",
"CookieName": "JSESSIONID"
}
],
"OtherPolicies": []
},
"LoadBalancerName": "<ELB_NAME>",
"CreatedTime": "2017-07-18T15:32:33.890Z",
"AvailabilityZones": [
"us-east-1a",
"us-east-1b",
"us-east-1c"
],
"Scheme": "internet-facing",
"SourceSecurityGroup": {
"OwnerAlias": "558554867759",
"GroupName": "<redacted>"
}
}
]
}
編輯3:有人嗎?請我越來越絕望我需要這個工作...
請捕捉一些請求和響應頭以說明AppCookieStickinessPolicies之一你的cookie「被刪除」。 –
@ Michael-sqlbot不知道如何做到這一點(再次,我真的是在網絡上的新東西)..我只是在鉻瀏覽cookie列表,並注意到AWSELB cookie不斷變化... – user1072692
你能使用AWS CLI發送負載均衡器配置的XML描述:'aws elb describe-load-balancers --load-balancer-name my-loadbalancer' –