requests: ConnectionError: ('Connection aborted.', BadStatusLine(""''''")) on Windows
I am encountering this error when making a PUT request on Windows only, It works fine on *nix.
requests.put(
https://upload.com,
timeout=None,
headers={
'Content-Length': 28689538,
'Content-Range': 'bytes: 0-28689538/28689538',
'User-Agent': 'test'
}, data=f)
File "C:\Python27\lib\site-packages\requests\api.py", line 105, in put
return request('put', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 408, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 31 (12 by maintainers)
Commits related to this issue
- Use safe_while to work around an OVH problem We're seeing intermittent network failures when running inside OVH; they present as: https://github.com/kennethreitz/requests/issues/2364 This should help... — committed to ceph/teuthology by zmc 9 years ago
- Use safe_while to work around an OVH problem We're seeing intermittent network failures when running inside OVH; they present as: https://github.com/kennethreitz/requests/issues/2364 This should help... — committed to SUSE/teuthology by zmc 9 years ago
I’ve just hit this issue too in Python requests 2.8.1.
In my case I’m making a large number of periodic https requests to a apache2 server with connection keep-alive timeout 5s. There is a race between the server closing a timed out persistent connection and the client making a request on the same connection. Given a bit of network latency the client can often attempt to send a request on the socket before it gets notified it as been closed.
Given my application (testing an API) I’m going to handle the specific exception that results with a retry or two.
It’s already re-wrapped. We do not (and will not) do exception message introspection. It would be great if we had better messages in the stdlib but trying to get features into httplib is harder than pulling teeth.
I usually see this when a proxy terminates a HTTPS connection. It can’t send back headers, because it can’t read the encrypted data going back and forth, so it sends back the empty string “”. httplib attempts to parse “” as “HTTP/1.x <status>” and fails with the above message.
How long did it take to fail?
Kevin Burke phone: 925.271.7005 | twentymilliseconds.com
On Mon, Dec 1, 2014 at 3:06 PM, Cory Benfield notifications@github.com wrote:
BadStatusLineis an exception coming out of the bowels ofhttplib, and it suggests that the data it receives doesn’t make any sense. If I had to guess, I’d say that the obvious error is related to the TLS connection you’re making. It would be interesting to see a packet capture (from tcpdump or wireshark) of this.