我有一个在 EC2 上的 tomcat 实例中运行的 Web 应用程序,我无法在我的一生中获得粘性会话来在负载均衡器上工作。我已经按照http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html中的所有步骤,尝试使用基于应用程序的(使用 JSESSIONID cookie)和时间-基于(使用 86400 秒)的方法,但无论哪种方式,它根本不起作用。同一用户不断在所有不同的节点周围反弹。每次他们点击网页上的新链接时,都会将他们反弹回主屏幕以再次登录。
我不知道为什么它不起作用。我对这些东西也不太了解(哎呀,直到 2 小时前,我什至不知道“粘性会话”是什么意思——不,我不能让别人去做)所以我'我也不确定从哪里开始调试它。
编辑:查看我的 cookie .. 每次我加载网站时,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:有人吗?请我越来越绝望我需要这个工作......