I have a problem with connections to ssl sockets in python
When I perform a stress test on the SMTP daemon that I am writing the client some sending threads die with " Connection reset by peer ", but server side does not there is no exception and I do not perform any handling on the socket that may be capturing the error.
The daemon is derived from the native python SMTPServer class and therefore uses asyncore.dispatcher to manage multiple connections
Client Error:
Exception in thread Thread-21:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 761, in run
self.__target(*self.__args, **self.__kwargs)
File "pop_bomb_client.py", line 45, in concurrent_thread
sendmess(k)
File "pop_bomb_client.py", line 31, in sendmess
sempop=smtplib.SMTP_SSL(server,465)
File "/usr/lib/python2.7/smtplib.py", line 781, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout)
File "/usr/lib/python2.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 311, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 787, in _get_socket
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
File "/usr/lib/python2.7/ssl.py", line 451, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 207, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 369, in do_handshake
self._sslobj.do_handshake()
error: [Errno 104] Connection reset by peer
SocketSSL on Server:
def create_socket(self, family, stype):
self.family_and_type = family, stype
sock = ssl.wrap_socket(socket.socket(family, stype),'cert.key', 'cert.cert',server_side=True, ssl_version=ssl.PROTOCOL_TLSv1)
sock.setblocking(0)
self.set_socket(sock)