K
K
Konstantin Alikhanov2017-06-15 11:37:19
Django
Konstantin Alikhanov, 2017-06-15 11:37:19

Why is django closing the connection prematurely?

Good afternoon. I ran into an annoying problem when sending requests from mobile applications to a Web API written in Django. During some requests, the connection is reset. Began to understand. As a result, I figured out such a simple django application . Easier already nowhere.
We call the /test/ method using the POST method and transfer some ~15MB binary data there,
test with curl and postman
on curl, everything is OK:

curl -X POST -d "@bin/ngrok" localhost:3000/test/

and on postman:
bb6e593b76954f81a08f8587c97e6aaf.png
At the same time, if you do not send binary data in the body, then everything is OK
7382a451c98545eb8fd3e6b94e1df95b.png
. In real projects, text data is sent - applicaiton/json, but I could reproduce it only in this way.
Comparing titles yielded nothing. I have no idea what the problem is. Content-Length postman and curl set themselves, it does not depend on content-type. Don't know.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Alikhanov, 2017-06-15
@atomAltera

In general, I found the answer. The fact is that Django starts sending the response before the client has time to send the request body in full. Apparently some HTTP clients are not designed for this. You just need to refer to request.body, and wait until it is all loaded, and only after that start scribbling the response

E
Eugene, 2017-06-15
@immaculate

In fact, Django never handles requests alone. It still has gunicorn/uwsgi/mod_wsgi and nginx or Apache in front of it. In addition, the restrictions on the size of the request are described right in the documentation .
Well, it would be nice to give the code and text of the error in such questions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question