0

我正在尝试使用 AWS java sdk 创建一个负载均衡器。但是我得到了状态码为 400 的 AmazonServiceException,但其他字段(如 AWS 请求 ID、AWS 错误代码等)为空。我无法了解问题所在。

下面是我用来创建负载均衡器的代码片段。

    elb = new AmazonElasticLoadBalancingClient(credentials);
    elb.setEndpoint("endPoint");



    CreateLoadBalancerRequest lbRequest = new CreateLoadBalancerRequest();
    lbRequest.setLoadBalancerName(lbName);
    List<Listener> listeners = new ArrayList<Listener>(1);
    listeners.add(new Listener(lbProtocol, lbPort, instancePort));
    lbRequest.withAvailabilityZones(availablezone1,availablezone2);
    lbRequest.setListeners(listeners);
    try{
         CreateLoadBalancerResult lbResult = elb.createLoadBalancer(lbRequest);
    } catch (AmazonServiceException e){
        e.printStackTrace();
    }catch (AmazonClientException e){
        e.printStackTrace();
    }

我收到以下异常:

状态代码:400,AWS 服务:AmazonElasticLoadBalancing,AWS 请求 ID:null,AWS 错误代码:null,AWS 错误消息:com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:583) at com.amazonaws.http .AmazonHttpClient.executeHelper(AmazonHttpClient.java:317) 在 com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:167) 在 com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient.invoke(AmazonElasticLoadBalancingClient.java:1224) 在 com。 amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient.createLoadBalancer(AmazonElasticLoadBalancingClient.java:675)

4

1 回答 1

3

尝试将端点更改为:https ://elasticloadbalancing.us-east-1.amazonaws.com

于 2012-10-04T07:50:32.067 回答