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.

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)

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
        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()}"')

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)
        message = "Knock knock, our messages are encrypted with ssl"

When I run the and then I get the following error

Traceback (most recent call last):
  File "C:\Users\whocares\Documents\", line 16, in <module>
    conn_stream = ctx.wrap_socket(client_socket, server_side=True)
  File "C:\Python39\lib\", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Python39\lib\", line 1040, in _create
  File "C:\Python39\lib\", line 1309, in 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