facebook/tornado — Issue #438: SSL socket errors
Author: hjwp
Created: 2012-01-17 15:28:05+00:00
State: open

We're seeing quite a few socket "Read error" and "Write error" in our logs. They're usually (but not absolutely always) associated with two C exceptions:

```WARNING:Read error on 25: [Errno 1] _ssl.c:1331: error:140943FC:SSL routines:SSL3_READ_BYTES:sslv3 alert bad record mac```

```WARNING:Write error on 21: [Errno 1] _ssl.c:1217: error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry```

The latter looks similar to the error discussed in the comments in `iostream.py`, and in python bug 8240. Could it be a slightly different case of the same bug?

When not associated with a C exception, we see only:

```WARNING:Write error on 18: [Errno 14] Bad address```

The first exception has a bit of google-juice too:
http://stackoverflow.com/questions/2603119/opening-ssl-urls-with-python
http://pythonpaste.org/news.html#id10

One thing that seems to help is running tornado from python 2.7 instead of python 2.6 - errors occur 5 times less frequently, in my last quick test (but sadly are not done away with completely)

Is there anything that can be done in the tornado code to try and avoid these? Or perhaps some way that we could use tornado differently to avoid them?