Python-docs-samples: raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out'))

Created on 21 Oct 2019  路  12Comments  路  Source: GoogleCloudPlatform/python-docs-samples

I'm trying to upload 90,000 files to the cloud from my harddrive, for a total 1.2 terrabytes. The first 3 files I was able to upload. The next three files I got the same error message. The files are also basically the same. They are just list of 3 dimensionals lists, which have strings as their members. The size of the first 3 files was under 15 megs, the size of the three that failed was 17 megs, 25 and 30 megs. This is my first time using Google Cloud and things are off to an incredibly bad start. If I can't upload my files, then of course I will have to kiss Google Cloud goodbye.

`Traceback (most recent call last):
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1055, in _send_output
self.send(chunk)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 977, in send
self.sock.sendall(data)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/ssl.py", line 1015, in sendall
v = self.send(byte_view[count:])
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/ssl.py", line 984, in send
return self._sslobj.write(data)
socket.timeout: The write operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 1055, in _send_output
self.send(chunk)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/http/client.py", line 977, in send
self.sock.sendall(data)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/ssl.py", line 1015, in sendall
v = self.send(byte_view[count:])
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/ssl.py", line 984, in send
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "begin.py", line 29, in
m2c.from_hd2cloud(iweb + 'as_lists1/', "as_lists1", 'as_lists1')
File "/users/kylefoley/codes/general/very_general_functions.py", line 18, in wrapper_timer
value = func(args, *kwargs)
File "/Users/kylefoley/codes/byu_corpus/move2cloud.py", line 83, in from_hd2cloud
upload_blob(bucket_name, f'{source_file_name}{x}', x)
File "/Users/kylefoley/codes/byu_corpus/move2cloud.py", line 66, in upload_blob
blob.upload_from_filename(source_file_name)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 1251, in upload_from_filename
predefined_acl=predefined_acl,
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 1196, in upload_from_file
client, file_obj, content_type, size, num_retries, predefined_acl
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 1106, in _do_upload
client, stream, content_type, size, num_retries, predefined_acl
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/cloud/storage/blob.py", line 1053, in _do_resumable_upload
response = upload.transmit_next_chunk(transport)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/resumable_media/requests/upload.py", line 425, in transmit_next_chunk
retry_strategy=self._retry_strategy,
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/resumable_media/requests/_helpers.py", line 116, in http_request
return _helpers.wait_and_retry(func, RequestsMixin._get_status_code, retry_strategy)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/resumable_media/_helpers.py", line 150, in wait_and_retry
response = func()
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/google/auth/transport/requests.py", line 208, in request
method, url, data=data, headers=request_headers, *kwargs)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, *
send_kwargs)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/Users/kylefoley/.pyenv/versions/3.7.3/lib/python3.7/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out'))`

needs more info p2 bug

Most helpful comment

I also have this problem trying to upload a 60 MB mp3 file (some much smaller mp3's worked fine, my upload bandwidth is ~1 mbps).

All 12 comments

Also maybe the culprit lies with my web connection. I tested it and currently I'm getting 2.8 Mbps upload speed.

UPDATE: It works on my home web connection which uploads at the speed of 10 megs a second. The error is a timeout error, so does that mean that if it fails to upload after a certain period that it raised an error? If that is the case then it should be quite easy to simply change the timeout threshold.

I still need an answer to this. My 2 meg per second connection to the internet is free and I use it 7 hours per day so I have to be able to upload data even if my web connection speed is 2 meg per second. Just because I can upload data with a 10 meg per second connection does not mean my problem is solved.

Hi @kylefoley76, I'm sorry you're having errors - thanks for pasting your output. In order for us to debug, we need to know a little bit more about your input - please let us know

  1. In which file did you encounter the issue? (please provide the full path to avoid ambiguity)

  2. Did you change the file? If so, how? (A diff would be helpful; otherwise, a description)

Also, since you're new to GCP, I wanted to recommend checking out this page which outlines all of our community support options.

I'm getting the exact same issue while uploading a 45MB file to GCP coldline bucket. @kylefoley76 have you found the cause of the issue?

Will look up the community forums and create a sample project to try and replicate.

@kylefoley76 PTAL

+1

I'm getting the same error while using GCP. Did anyone figure out a fix for this?

I still need an answer to this. My 2 meg per second connection to the internet is free and I use it 7 hours per day so I have to be able to upload data even if my web connection speed is 2 meg per second. Just because I can upload data with a 10 meg per second connection does not mean my problem is solved.

Did you figure it out, anyhow?

Sorry to say this, but I'm going to close this issue.

I feel sorry because it seems that several people are experiencing the same thing and frustrated. However, to solve the issue, at least we need to know how to reproduce the problem. I read the comments, but I could not find enough information to reproduce the problem.

I'm closing this, but feel free to re-open the issue with repro.

Thanks,

I also have this problem trying to upload a 60 MB mp3 file (some much smaller mp3's worked fine, my upload bandwidth is ~1 mbps).

This workaround worked for me:

from google.cloud import storage
# WARNING; WORKAROUND to prevent timeout for files > 6 MB on 800 kbps upload link.
storage.blob._DEFAULT_CHUNKSIZE = 5 * 1024* 1024  # 5 MB
storage.blob._MAX_MULTIPART_SIZE = 5 * 1024* 1024  # 5 MB

This solution is consistent with the idea it's an issue if and only if one is uploading a file that takes more than a minute to upload and also has a slow upload transfer rate (e.g., <1.1 Mbps).

Was this page helpful?
0 / 5 - 0 ratings