{"action":"created","issue":{"url":"https://api.github.com/repos/boto/boto/issues/621","labels_url":"https://api.github.com/repos/boto/boto/issues/621/labels{/name}","comments_url":"https://api.github.com/repos/boto/boto/issues/621/comments","events_url":"https://api.github.com/repos/boto/boto/issues/621/events","html_url":"https://github.com/boto/boto/issues/621","id":3539239,"number":621,"title":"broken pipe error, non US-Standard region","user":{"login":"jkarneges","id":521953,"avatar_url":"https://avatars.githubusercontent.com/u/521953?v=3","gravatar_id":"","url":"https://api.github.com/users/jkarneges","html_url":"https://github.com/jkarneges","followers_url":"https://api.github.com/users/jkarneges/followers","following_url":"https://api.github.com/users/jkarneges/following{/other_user}","gists_url":"https://api.github.com/users/jkarneges/gists{/gist_id}","starred_url":"https://api.github.com/users/jkarneges/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkarneges/subscriptions","organizations_url":"https://api.github.com/users/jkarneges/orgs","repos_url":"https://api.github.com/users/jkarneges/repos","events_url":"https://api.github.com/users/jkarneges/events{/privacy}","received_events_url":"https://api.github.com/users/jkarneges/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":40,"created_at":"2012-03-07T08:11:37Z","updated_at":"2015-07-16T14:17:44Z","closed_at":null,"body":"My S3 region is Northern California, aka us-west-1.  Uploads almost always fail after some timeout period, even if the files are \"small\" (<200K).  I'm using boto 2.2.2 and python 2.7.2.  The uploads are being made from an EC2 machine in the same region.\r\n\r\nHere's the exception I always get:\r\n\r\n```python\r\nTraceback (most recent call last):\r\n  File \"backup_to_s3.py\", line 25, in <module>\r\n    k.set_contents_from_filename(\"/tmp/%s\" % dumpfile)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/s3/key.py\", line 969, in set_contents_from_filename\r\n    encrypt_key=encrypt_key)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/s3/key.py\", line 902, in set_contents_from_file\r\n    size=size)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/s3/key.py\", line 660, in send_file\r\n    query_args=query_args)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py\", line 449, in make_request\r\n    override_num_retries=override_num_retries)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/connection.py\", line 829, in make_request\r\n    return self._mexe(http_request, sender, override_num_retries)\r\n  File \"/usr/local/lib/python2.7/dist-packages/boto/connection.py\", line 794, in _mexe\r\n    raise e\r\nsocket.error: [Errno 32] Broken pipe\r\n```\r\n\r\nI used is_secure=False and tcpdump to inspect what was happening.  It looks like by default requests from boto are sent to the primary S3 host, which then responds with redirects to the correct region using HTTP code 307.  While boto does honor the 307 for some exchanges, it seems not to for PUT, or at least not consistently, and so I think this is what is causing the failures.\r\n\r\nPassing host=\"s3-us-west-1.amazonaws.com\" to S3Connection's constructor solved the problem for me."},"comment":{"url":"https://api.github.com/repos/boto/boto/issues/comments/121969637","html_url":"https://github.com/boto/boto/issues/621#issuecomment-121969637","issue_url":"https://api.github.com/repos/boto/boto/issues/621","id":121969637,"user":{"login":"ddahan","id":1933516,"avatar_url":"https://avatars.githubusercontent.com/u/1933516?v=3","gravatar_id":"","url":"https://api.github.com/users/ddahan","html_url":"https://github.com/ddahan","followers_url":"https://api.github.com/users/ddahan/followers","following_url":"https://api.github.com/users/ddahan/following{/other_user}","gists_url":"https://api.github.com/users/ddahan/gists{/gist_id}","starred_url":"https://api.github.com/users/ddahan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddahan/subscriptions","organizations_url":"https://api.github.com/users/ddahan/orgs","repos_url":"https://api.github.com/users/ddahan/repos","events_url":"https://api.github.com/users/ddahan/events{/privacy}","received_events_url":"https://api.github.com/users/ddahan/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T14:17:44Z","updated_at":"2015-07-16T14:17:44Z","body":"+1 for shredding tip! Thanks!"}}