Imorting Sales using SDK error ''unexpected end of stream''

I have a question about an error that we stumble upon recently. We are using Square SDK in order to get sales data. Almost each of the requests fails with:
{“message”:"unexpected end of stream on https://connect.squareup.com/[...",“status”:500,“path”:"/sales/extract-from-square",“timestamp”:“2021-12-21T10:27:55.737+0000”}]
Could you advise please what might have caused the above error and how to fix it?
Thanks in advance!

What SDK are you using and what’s your applicationId? I believe this is a server error and what I’m finding is that the server threw the error and shut down as it is parsing the request before getting to Square servers. :slightly_smiling_face:

Hello Bryan, thanks for your interest. the applicationid we are using is sq0idp-vT1vg_OklnRCT2iweK29Fg and the SDK is 17.0.0.20211117.
The method we are calling is:

private List<Payment> getPaymentsInTimeInterval(Instant from, Instant to, SquareClient square) throws IOException, ApiException {
    int count = 0;
    String cursor = null;
    List<Payment> payments = new ArrayList<>();
    PaymentsApi paymentsApi = square.getPaymentsApi();
    do {
        ListPaymentsResponse response = paymentsApi
                .listPayments(from.toString(), to.toString(), null, cursor, null, null, null, null, 100);
        if (!CollectionUtils.isEmpty(response.getPayments())) {
            payments.addAll(response.getPayments());
        }

        cursor = response.getCursor();
        count++;
    } while (StringUtils.hasText(cursor) && count < 100);
    return payments;
}


And it returns the error I gave above. Although I will attach the error stream as well as a text file in case is helpful. 
https://we.tl/t-XKoGELZc4z

Hello Bryan, Thanks for your interest. So the SDK we are using is 17.0.0.20211117, and the application id is sq0idp-vT1vg_OklnRCT2iweK29Fg.

Hello @Bryan-Square do you have any updates related to our bug?

Is there any more information that’s included with that error message? That doesn’t look like a Square error message and looking at your logs I don’t see any errors being returned from our servers.

The first try to pull the data gives the above error, the second try works with no errors. There is no more information included with the error, but if you need anything else to be provided please don’t hesitate to let me know.

@Bryan-Square above you can see the method we are using, it has been deleted by one of the Square members and they put it online just yesterday.

Hi @Marty! :wave: If you’re having occasional issues hitting the API endpoints, you may want to consider configuring the SDK to retry failed requests.