1
votes

I have a problem with a bulk itemlookup

com.sun.xml.internal.ws.client.ClientTransportException:

   com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 503: Service Unavailable

com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 503: Service Unavailable at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(HttpTransportPipe.java:296) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:245) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:203) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:122) at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95) at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:626) at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:585) at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:570) at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:467) at com.sun.xml.internal.ws.client.Stub.process(Stub.java:308) at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:146) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129) at $Proxy29.itemLookup(Unknown Source)

This itemLookup is made with the following request:

    List<String> resGroup = new ArrayList<String>();
    resGroup.add("Offers");
    resGroup.add("Images");
    resGroup.add("ItemAttributes");
    resGroup.add("ItemIds");

    ItemLookupRequest request = new ItemLookupRequest();
    request.getItemId().addAll(asins);  //asins is an ArrayList<String> of 10 asins
    request.setMerchantId(merchant);
    request.setCondition(condition);
    request.getResponseGroup().addAll(resGroup);

    ItemLookup itemLookup = new ItemLookup();

    itemLookup.setAWSAccessKeyId(AWS_ACCESS_KEY);
    itemLookup.setAssociateTag(ASSOC_TAGS.get("en-GB"));
    itemLookup.getRequest().add(request);

    response = port.itemLookup(itemLookup);   **<-- This line throws the Exception**

This code has worked for 3 years, looking up around 26,000 items in batches of 10 once every 24 hours with no problems, but on the following dates has returned the 503 for every single lookup made that day.

05.04.2015, 06.04.2015

26.04.2015

05.08.2015

25.12.2015, 26.12.2015

25.01.2016 to 02.02.2016 inclusive

The only suggestion in Amazon Product Advertising API documentation is that the 503 is caused by throttling, with the advice to reduce the number of requests sent per second. Throttling should not be an issue on every single lookup. If it was due to throttling the lookups would at first be successful and only return the 503 after the hourly quota has been reached. This is not the case, on the given dates there have been zero successful lookups with the service resuming as normal at all other times.

1

1 Answers

0
votes

I also encounter 503 errors, but when I repeat the request, it may be successful. Try this:

int retries = 0;
while (retries < 3){

    Thread.sleep(1500 * retries);

    try{
        response = port.itemLookup(itemLookup);
        break;
    }
    catch(Exception ex){ }
    retries++;
}

Hope this helps.