We have a django app and it supports a file upload request. The entire upload comprises multiple requests. We are authenticating with JWT and we have logic to handle a 401 and in that case use the refresh token to get a new access token and resend the failed request. However if the token expires between 2 requests of the same upload the 401 response never makes it to the client. In the logs I found that before nginx gets the response we get this error:
2023/06/02 16:23:11 [error] 1924925#1924925: *75 readv() failed (104: Connection reset by peer) while reading upstream, client: xx.xx.xx.xx, server: foo.com, request: "POST /api/upload/ HTTP/1.1", upstream: "uwsgi://unix:///bar/foo/our_app/app.sock:", host: "foo.com", referrer: "http://foo.com:8082/" This causes the client to get an empty response body and the browser throws a ERR_CONTENT_LENGTH_MISMATCH error. The entire upload takes under 10 minutes and we have all the timeouts set to 100 minutes: uwsgi_read_timeout 6000; uwsgi_connect_timeout 6000; uwsgi_send_timeout 6000; send_timeout 6000; proxy_read_timeout 6000; proxy_send_timeout 6000; What is causing the socket to get closed? How can I prevent that? Are there other timeouts I could set? Any logging that I can enable to see why the socket is getting closed? Is there a way to detect this in code so it can be retried? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY6ShL02Hhnfbc-uGTsMdKBNV8ij6kom7n9hJndwpRQGwg%40mail.gmail.com.