Django Rest Framework fails to return a response if response it too large. http code 0

Viewed 359

We are building an API on Django and using the Django Rest Framework. This API sits between two servers, so it receives requests from server A, makes requests to server B, formats the response from server B and responds back to server A with the formatted data.

The view handler extends the ApiView class from DRF, and the response is a Response object from DRF as well.

Here is pseudo code from views.py to put things into perspective:

class dummy(APIView)

    # define auth here

    def get(request):

        # handle the request from server A

        # get the content here, from server B

        # content is a list of up to 1028 elements

        response = Response({'status':'success','content':content}, status=200)
        return response <--- fails here if content length > 200 elements

The content is a list of dicts, each dicts contain 4 - 5 key/value pairs, if this list is less than 200 elements long, the response goes through just fine, but anything above 200 elements will result in a response code 0 and no error message explaining what happened, other than a broken pipeerror from server A.

We increased the timeout on the request from server A to 30 seconds, just to be sure and it changes nothing, the error also happens much faster than 30 seconds, so we know that Server A is not thinking that the API timed out.

Server B responds exactly as expected, and we get no errors from it.

This is just text being passed through, no long strings or encoded data, is there a Response size limit to Django Rest Framework? I could not find any reference to that, I only saw request size limits.

We are trying to avoid pagination, but I am aware that it is an option if all else fails, it just surprises me that a response with at most 5000 lines of text could break the DRF.

0 Answers
Related