9
I have a problem with connections with Sockets ssl in python
When performing a stress test on the SMTP daemon I am writing the client some sending threads die with "Connection reset by peer" , however on the server side there is no Exception and I do not perform any treatment on the socket that might be capturing the error.
The daemon is derived from the native python class Smtpserver and therefore uses asyncore.Dispatcher to manage multiple connections
Error in client:
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 in the 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)
Have you checked your certificates? Are they expired or are they self-signed? If so, have you seen if the customer is not rejecting the connection for this and you need to enable something to force him to accept?
– Alexandre Marcondes
yes, it is a valid certificate and this ok, I did tests with a fake and the only thing was to accept the certificate in Thunderbird, after accepting once it was already working without any problem... the error I have is only in front of load... I think in practice is my bot client that is not performing... the server nor feel with 20 simultaneous connections..
– BrenoZan
Enter the code of how you are running the threads. There are load related problems. What type of server you are using to run the server?
– Jones
It would be interesting to have access to your client’s code
– planestepper