We have an ajax upload that uploads files to our django app, that
uploads to S3 storage via Boto. We keep seeing error: [Errno 32]
Broken pipe generated in connections.py(or errno 110 Connection timed
out), with the traceback is pasted below.
* The error is intermittent, and happens at seemingly random times.
We've been testing various factors over the past week.
* It is not a filesize issue, since sometimes we're to upload larger
files(2-20+ MB), but have smaller files fail(less than 2MB).
* Tried setting boto connection is_secure to both True,False so that
it uses an http/https connection. But it still fails on both of them.
* We've don't seem to have any other network, connectivity issues with
S3. We do our static media sync to s3 and that has never failed in
over a year. Infact just before upload everytime the s3storage checks
for collision of filenames with a GET and that has never failed. So
i'm pretty sure it's not a connectivity issue.
* When failing the control always hangs at connection.py:
response = sender(connection, method, path, data, headers)
and then times out(after 15 minutes approx) and retries 4 more times
in quick succession. I've only seen the connection timed out error the
first time(but even that is a broken pipe usually), the others are
always Broken pipe.
* We thought it might have been an apache issue and upon research we
came across some other solutions that suggested keepalive off. We've
tried that and it still happens.
* We have spun-up 4 different EC2 instances and tried our app on all
of them, on different ubuntu versions (jaunty, lucid) figuring it
might be a version issue.
* We've also tried boto v1.9b, boto v2.02b and as git checkout of
2.0b3 which was as recent as some hours ago, with the same errors.
* We also tried using a completely different S3 account/buckets to no
avail.
* At this point majority of our uploads fail, with django generating
an error email on the offending line pasted above.
Also quite often we see a RequestTimeTooSkewed Error from S3, and our
server time now is synced via ntp every 5 mins so it's certainly not a
timing issue as we thought earlier. But it might be related to the
above 15 minute timeouts, which exceed Amazons request time limits.
Our Stack:
Ubuntu Lucid
django 1.1.1
Apache/2.2.16
mod_ssl/2.2.14
OpenSSL/0.9.8k
mod_wsgi/2.8
Python/2.6.5
----------------------------------------
I added a callback to set_contents_from_file ``cb`` kwarg to show me
how much of the file was getting transfered. It usually used to be
stuck at 0bytes when we were testing with is_secure=True. We switched
to http and our latest traceback shows some data did make it through
Traceback:
[Thu Oct 07 23:53:07 2010] [error] Canonical: PUT
[Thu Oct 07 23:53:07 2010] [error] I9b0xynC0Er2hBKKp1xfpQ==
[Thu Oct 07 23:53:07 2010] [error] application/pdf
[Thu Oct 07 23:53:07 2010] [error] Fri, 08 Oct 2010 03:53:07 GMT
[Thu Oct 07 23:53:07 2010] [error] /
media.qa.some_app.com/media/dmt/
2010/wcdoedgqnh/Amendment%20No.%202%20to%20Registration%20Statement
%20on%20Form%20S-1.pdf___
[Thu Oct 07 23:53:07 2010] [error] Method: PUT
[Thu Oct 07 23:53:07 2010] [error] Path: /media/dmt/2010/wcdoedgqnh/
Amendment%20No.%202%20to%20Registration%20Statement%20on%20Form
%20S-1.pdf___
[Thu Oct 07 23:53:07 2010] [error] Data:
[Thu Oct 07 23:53:07 2010] [error] Headers: {'Content-MD5':
'I9b0ab2hBKKp1xfpQ==', 'Content-Length': '2127937', 'Expect': '100-
Continue', 'Date': 'Fri, 08 Oct 2010 03:53:07 GMT', 'Expires': 'Sun,
04 Oct 2020 23:53:07 GMT', 'Content-Type': 'application/pdf',
'Authorization': 'AWS AKIAIZI47OHXASDADZUZNUA:RkID
+Ry8/4bclktjUnljbau5s9s=', 'User-Agent': 'Boto/2.0b3 (linux2)'}
[Thu Oct 07 23:53:07 2010] [error] Host:
media.qa.some_app.com.s3.amazonaws.com
[Thu Oct 07 23:53:07 2010] [error] Callback from S3 call: 0 bytes
sent, 2127937 bytes left
[Thu Oct 07 23:53:07 2010] [error] =============
[Fri Oct 08 00:02:27 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:27 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:27 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:27 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:27 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:27 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:27 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:27 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:27 2010] [error] error: [Errno 110] Connection timed
out
[Fri Oct 08 00:02:27 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:27 2010] [error] establishing HTTP connection
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 0 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 16384 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 32768 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 49152 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 65536 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] Callback from S3 call: 81920 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:28 2010] [error] =============
[Fri Oct 08 00:02:28 2010] [error] -------------------------
[Fri Oct 08 00:02:28 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:28 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:28 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:28 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:28 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:28 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:28 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:28 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:28 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:02:28 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:28 2010] [error] establishing HTTP connection
[Fri Oct 08 00:02:30 2010] [error] Callback from S3 call: 0 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:30 2010] [error] =============
[Fri Oct 08 00:02:30 2010] [error] Callback from S3 call: 16384 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:30 2010] [error] =============
[Fri Oct 08 00:02:30 2010] [error] Callback from S3 call: 32768 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:30 2010] [error] =============
[Fri Oct 08 00:02:30 2010] [error] Callback from S3 call: 49152 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:30 2010] [error] =============
[Fri Oct 08 00:02:30 2010] [error] Callback from S3 call: 65536 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:30 2010] [error] =============
[Fri Oct 08 00:02:30 2010] [error] -------------------------
[Fri Oct 08 00:02:30 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:30 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:30 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:30 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:30 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:30 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:30 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:02:30 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:30 2010] [error] establishing HTTP connection
[Fri Oct 08 00:02:34 2010] [error] Callback from S3 call: 0 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:34 2010] [error] =============
[Fri Oct 08 00:02:34 2010] [error] Callback from S3 call: 16384 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:34 2010] [error] =============
[Fri Oct 08 00:02:34 2010] [error] Callback from S3 call: 32768 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:34 2010] [error] =============
[Fri Oct 08 00:02:34 2010] [error] Callback from S3 call: 49152 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:34 2010] [error] =============
[Fri Oct 08 00:02:34 2010] [error] Callback from S3 call: 65536 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:34 2010] [error] =============
[Fri Oct 08 00:02:34 2010] [error] -------------------------
[Fri Oct 08 00:02:34 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:34 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:34 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:34 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:34 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:34 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:34 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:34 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:34 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:02:34 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:34 2010] [error] establishing HTTP connection
[Fri Oct 08 00:02:42 2010] [error] Callback from S3 call: 0 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:42 2010] [error] =============
[Fri Oct 08 00:02:42 2010] [error] Callback from S3 call: 16384 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:42 2010] [error] =============
[Fri Oct 08 00:02:42 2010] [error] Callback from S3 call: 32768 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:42 2010] [error] =============
[Fri Oct 08 00:02:42 2010] [error] Callback from S3 call: 49152 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:42 2010] [error] =============
[Fri Oct 08 00:02:42 2010] [error] Callback from S3 call: 65536 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:42 2010] [error] =============
[Fri Oct 08 00:02:42 2010] [error] -------------------------
[Fri Oct 08 00:02:42 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:42 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:42 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:42 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:42 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:42 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:42 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:42 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:42 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:02:42 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:42 2010] [error] establishing HTTP connection
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 0 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 16384 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 32768 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 49152 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 65536 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] Callback from S3 call: 81920 bytes
sent, 143550 bytes left
[Fri Oct 08 00:02:58 2010] [error] =============
[Fri Oct 08 00:02:58 2010] [error] -------------------------
[Fri Oct 08 00:02:58 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:02:58 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 414, in _mexe
[Fri Oct 08 00:02:58 2010] [error] response = sender(connection,
method, path, data, headers)
[Fri Oct 08 00:02:58 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 457, in sender
[Fri Oct 08 00:02:58 2010] [error] http_conn.send(l)
[Fri Oct 08 00:02:58 2010] [error] File "/usr/lib/python2.6/
httplib.py", line 755, in send
[Fri Oct 08 00:02:58 2010] [error] self.sock.sendall(str)
[Fri Oct 08 00:02:58 2010] [error] File "<string>", line 1, in
sendall
[Fri Oct 08 00:02:58 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:02:58 2010] [error] encountered error exception,
reconnecting
[Fri Oct 08 00:02:58 2010] [error] establishing HTTP connection
[Fri Oct 08 00:03:30 2010] [error] Traceback (most recent call last):
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/core/handlers/base.py",
line 92, in get_response
[Fri Oct 08 00:03:30 2010] [error] response = callback(request,
*callback_args, **callback_kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/common/decorators.py", line 13, in new_func
[Fri Oct 08 00:03:30 2010] [error] return view_func(request,
*args, **kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/common/decorators.py", line 24, in new_func
[Fri Oct 08 00:03:30 2010] [error] return view_func(request,
*args, **kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/common/decorators.py", line 36, in new_func
[Fri Oct 08 00:03:30 2010] [error] return view_func(request,
*args, **kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/contrib/auth/
decorators.py", line 78, in __call__
[Fri Oct 08 00:03:30 2010] [error] return self.view_func(request,
*args, **kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/app/profiles/views/expert.py", line 512, in upload_avatar
[Fri Oct 08 00:03:30 2010] [error] user_profile = form.save()
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/forms/models.py", line
407, in save
[Fri Oct 08 00:03:30 2010] [error] fail_message, commit,
exclude=self._meta.exclude)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/forms/models.py", line 78,
in save_instance
[Fri Oct 08 00:03:30 2010] [error] instance.save()
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/app/profiles/models.py", line 123, in save
[Fri Oct 08 00:03:30 2010] [error] super(UserProfile,
self).save(*args, **kwargs)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/db/models/base.py", line
410, in save
[Fri Oct 08 00:03:30 2010] [error]
self.save_base(force_insert=force_insert, force_update=force_update)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/db/models/base.py", line
473, in save_base
[Fri Oct 08 00:03:30 2010] [error] values = [(f, None, (raw and
getattr(self, f.attname) or f.pre_save(self, False))) for f in
non_pks]
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/db/models/fields/
files.py", line 252, in pre_save
[Fri Oct 08 00:03:30 2010] [error] file.save(
file.name, file,
save=False)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/lib/thumbs.py", line 103, in save
[Fri Oct 08 00:03:30 2010] [error] super(ImageWithThumbsFieldFile,
self).save(name, content, save)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/lib/python2.6/site-packages/django/db/models/fields/
files.py", line 91, in save
[Fri Oct 08 00:03:30 2010] [error]
self.name =
self.storage.save(name, content)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/lib/storage/s3.py", line 135, in save
[Fri Oct 08 00:03:30 2010] [error] return
super(S3HashFilenameStorage, self).save(filename, content)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/webapps/
some_app/lib/storage/s3.py", line 97, in save
[Fri Oct 08 00:03:30 2010] [error]
new_key.set_contents_from_file(content, headers=headers,
cb=self._set_contents_from_file_callback)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 618, in set_contents_from_file
[Fri Oct 08 00:03:30 2010] [error] self.send_file(fp, headers, cb,
num_cb)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/key.py", line 510, in send_file
[Fri Oct 08 00:03:30 2010] [error] sender=sender)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/s3/connection.py", line 399, in make_request
[Fri Oct 08 00:03:30 2010] [error]
override_num_retries=override_num_retries)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 500, in make_request
[Fri Oct 08 00:03:30 2010] [error] override_num_retries)
[Fri Oct 08 00:03:30 2010] [error] File "/home/ubuntu/.virtualenvs/
some_app/src/boto/boto/connection.py", line 465, in _mexe
[Fri Oct 08 00:03:30 2010] [error] raise e
[Fri Oct 08 00:03:30 2010] [error] error: [Errno 32] Broken pipe
[Fri Oct 08 00:03:30 2010] [error]
[Fri Oct 08 00:03:32 2010] [info] [client 98.14.140.241]
(104)Connection reset by peer: core_output_filter: writing data to the
network
[Fri Oct 08 00:03:32 2010] [error] [client 98.14.140.241] mod_wsgi
(pid=27186): Exception occurred processing WSGI script '/home/ubuntu/
webapps/some_app/settings/apache/
qa.wsgi.py'., referer:
https://qa.some_app.com/profiles/edit/
[Fri Oct 08 00:03:32 2010] [error] [client 98.14.140.241] IOError:
failed to write data, referer:
https://qa.some_app.com/profiles/edit/