Skip to content Skip to sidebar Skip to footer

Connection Aborted.', Badstatusline("''",) On Server?

I use the following code to get image from network: path = 'http://domgvozdem.ru/images/ustanovka-kondicionera-svoimi-rukami.jpg' def exists(path): r = requests.head(path)

Solution 1:

You get this error when your Python client receives an empty response (header /body).

BTW newer Python version will throw a different Exception, It can happen when the server disconnects the connections, or a network issue.

In my case, we spent some weeks trying to reproduce it until we found the main cause, We have a Python application sending requests to a service behind Nginx loadbalancer,

We found that Nginx disconnects the connection when the client exceeded the default Nginx configurations client_header_timeout / client_body_timeout (60 sec), it's the time that Nginx will wait for additional data packet from the client.

You can follow this reference http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout

When our application is loaded with CPU processing, connections are established but header and request body have a long delay until transmitted, over 82 seconds.

So Nginx closes the connection and returns reset packet (recorded tcpdump with empty body and headers), officially it should return status code 408, which is not happening.

We solved it by increasing the client_header_timeout / client_body_timeout to 180s for both params:

server {
..
client_body_timeout 180s;
client_header_timeout 180s;
}

Post a Comment for "Connection Aborted.', Badstatusline("''",) On Server?"