To send a tweet with a picture - BrokenPipeError: [Errno 32] Broken pipe


Hello everyone,
I’m in the process of creating a Python software procedure - my main purpose in to send a tweet with a picture. I’m using the library built for the twitter platform “Python Twitter Tools” (
If I run the application in a Unix machine (Centos) the system generates the following error message: BrokenPipeError: [Errno 32] Broken pipe
Instead if I decide to run the same application in a machine with windows operating system no message error appears and the operations succeeds.

Would anyone be able to tell me why?

Thanks a lot in advance.

Best wishes,

Source code:

# Send a tweet with an image included (or set your banner or logo similarily)
# by just reading your image from the web or a file in a string:
with open(status, "rb") as imagefile:
    params = {"media[]":, "status": "Test invio immagine..."}
outcome = t.statuses.update_with_media(**params)

Traceback (most recent call last):

File “/usr/local/lib/python3.3/urllib/”, line 1248, in do_open
h.request(req.get_method(), req.selector,, headers)
File “/usr/local/lib/python3.3/http/”, line 1061, in request
self._send_request(method, url, body, headers)
File “/usr/local/lib/python3.3/http/”, line 1099, in _send_request
File “/usr/local/lib/python3.3/http/”, line 1057, in endheaders
File “/usr/local/lib/python3.3/http/”, line 902, in _send_output
File “/usr/local/lib/python3.3/http/”, line 871, in send
File “/usr/local/lib/python3.3/”, line 425, in sendall
v = self.send(data[count:])
File “/usr/local/lib/python3.3/”, line 386, in send
v = self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/dstar/tmp/”, line 53, in
File “/dstar/tmp/”, line 49, in polling
File “/dstar/tmp/”, line 31, in send_to_twitter
outcome = t.statuses.update_with_media(**params)
File “/usr/local/lib/python3.3/site-packages/twitter-1.10.0-py3.3.egg/twitter/”, line 204, in call
return self._handle_response(req, uri, arg_data, _timeout)
File “/usr/local/lib/python3.3/site-packages/twitter-1.10.0-py3.3.egg/twitter/”, line 211, in _handle_response
handle = urllib_request.urlopen(req, **kwargs)
File “/usr/local/lib/python3.3/urllib/”, line 156, in urlopen
return, data, timeout)
File “/usr/local/lib/python3.3/urllib/”, line 469, in open
response = self._open(req, data)
File “/usr/local/lib/python3.3/urllib/”, line 487, in _open
’_open’, req)
File “/usr/local/lib/python3.3/urllib/”, line 447, in _call_chain
result = func(*args)
File “/usr/local/lib/python3.3/urllib/”, line 1283, in https_open
context=self._context, check_hostname=self._check_hostname)
File “/usr/local/lib/python3.3/urllib/”, line 1251, in do_open
raise URLError(err)
urllib.error.URLError: urlopen error [Errno 32] Broken pipe>

Trace TCP/IP:

19:21:53.180764 IP > 30001 [1au] AAAA? (44)
19:21:53.225168 IP > 30001*- 0/1/1 (116)
19:21:53.227612 IP > 32103 [1au] A? (44)
19:21:53.299637 IP > 32103*- 4/4/1 A,[|domain]
19:21:53.305391 IP > S 1062698777:1062698777(0) win 5840 <mss 1460,sackOK,timestamp 350447671 0,nop,wscale 7>
19:21:53.461770 IP > S 898493203:898493203(0) ack 1062698778 win 14480 <mss 1440,sackOK,timestamp 179084769 350447671,nop,wscale 8>
19:21:53.461802 IP > . ack 1 win 46 <nop,nop,timestamp 350447827 179084769>
19:21:53.462067 IP > P 1:73(72) ack 1 win 46 <nop,nop,timestamp 350447827 179084769>
19:21:53.593662 IP > . ack 73 win 57 <nop,nop,timestamp 179084900 350447827>
19:21:53.594277 IP > . 1:1401(1400) ack 73 win 57 <nop,nop,timestamp 179084900 350447827>
19:21:53.594773 IP > . 1401:2801(1400) ack 73 win 57 <nop,nop,timestamp 179084900 350447827>
19:21:53.595596 IP > P 2801:2936(135) ack 73 win 57 <nop,nop,timestamp 179084900 350447827>
19:21:53.596048 IP > . ack 1401 win 69 <nop,nop,timestamp 350447961 179084900>
19:21:53.596056 IP > . ack 2801 win 91 <nop,nop,timestamp 350447961 179084900>
19:21:53.596060 IP > . ack 2936 win 113 <nop,nop,timestamp 350447961 179084900>
19:21:53.596757 IP > P 73:399(326) ack 2936 win 113 <nop,nop,timestamp 350447962 179084900>

19:21:56.422471 IP > P 106821:108249(1428) ack 2995 win 113 <nop,nop,timestamp 350450788 179087730>
19:21:56.422476 IP > . 108249:109677(1428) ack 2995 win 113 <nop,nop,timestamp 350450788 179087730>
19:21:56.422754 IP > P 2995:3176(181) ack 99681 win 59 <nop,nop,timestamp 179087730 350450548>
19:21:56.423218 IP > P 3176:3213(37) ack 99681 win 61 <nop,nop,timestamp 179087730 350450548>
19:21:56.424783 IP > F 3213:3213(0) ack 99681 win 61 <nop,nop,timestamp 179087730 350450548>
19:21:56.430299 IP > R 898496198:898496198(0) win 0
19:21:56.441472 IP > R 898496198:898496198(0) win 0


It looks like it could be an SSL issue, given the point in the code at which the error occurs. I can’t be sure though.

Have you tried raising the issue with the author of the library specifically? (ah yes, I can see you have!)


Hello Andy,
First of all thank you very much for your reply, the only one I got so far.It appears to be a big challenge…
Would you give me a hand on that? Do you know anyone I could chat with to understand better what’s going on? Do you think this is a problem in the Unix environment? If we had a SSL issue, what do you think I can do about it?

Thanks again for all your support.

Best regards,


I don’t have a CentOS machine handy to test this myself.

If it was me :wink: I would probably check the version of OpenSSL installed is up-to-date; check your hostname is set correctly and can be read from Python; check the timezone and time setting matches the correct time (and check whether this is the same on the Windows machine); and try making some basic requests to HTTPS endpoints on different sites from a simple Python script.

Those are some simple debugging steps that might help you get to the bottom of the issue.


Another thing to check is that the file size doesn’t exceed the limit on the Twitter API, but I’m guessing you’re trying to post the exact same image from both Windows and CentOS (and I think your script is failing before you even get to this point, so it is far less likely to be an issue).


Hello Andy,
Thank you so much for you feedback.
I followed your suggestions and these are the results I obtained:

  • O.S.: CentOS release 5.11 (Final)

  • Openssl: Package openssl-0.9.8e-31.el5_11.i686 already installed and latest version Nothing to do

  • the Python script:
    import socket

    gives me the following result:
    ir0up.localdomain - Is it correct?

  • the “date” command gives me back the following result:
    mer nov 26 12:59:24 CET 2014 - The time is correct.

  • the Python script:

    import http.client

    c = http.client.HTTPSConnection(
    c.request(“GET”, “/”)
    response = c.getresponse()
    print(response.status, response.reason)
    data =

    gives me the following result:
    200 OK

Finally, I’d like to confirm you that the image I send is the same either for o.s. Windows or o.s. Centos.

Thanks once again for all your kind support!

Best regards,


The hostname looks strange - what result do you get on Windows? That looks like a local domain, not an interface that is connected to the Internet.