Connection closes between client and server communicating using ssl socket with self signed certificate

I am trying to simulate an ssl encrypted comminication over TCP between server and client on localhost with self signed certificate. I don't care to verification, so I have disabled the security in client context.

server.py

import ssl
import socket

cert_file = "cert.pem" #contains the private key and the certificate

server_addr = ('localhost', 8888)

if __name__ == "__main__":
    ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    ctx.load_cert_chain(cert_file)

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
        server_socket.bind(server_addr)
        server_socket.listen(1)
        client_socket, _ = server_socket.accept()
        conn_stream = ctx.wrap_socket(client_socket, server_side=True)
        message = conn_stream.recv(1024)
        print(f'Client sent - "{message.decode()}"')
        conn_stream.close()

client.py

import ssl
import socket


server_addr = ('localhost', 8888)

if __name__ == "__main__":
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
        ssl_socket = ctx.wrap_socket(client_socket)
        ssl_socket.connect(server_addr)
        message = "Knock knock, our messages are encrypted with ssl"
        ssl_socket.send(message.encode())
        ssl_socket.close()

When I run the server.py and then client.py I get the following error

Traceback (most recent call last):
  File "C:\Users\whocares\Documents\server.py", line 16, in <module>
    conn_stream = ctx.wrap_socket(client_socket, server_side=True)
  File "C:\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

What am I doing wrong here? How do I successfully send the message with SSL?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum