Websocket Client not recieving message from server (Handshake OK, Server recieves messages)

My server establishes a connection with the JavaScript client, and upon opening, the server sends a message to the client. However, the client does not receive this message. The client successfully sends messages to the server after the connection opens, and the server receives these and all subsequent messages. Despite this, no messages sent by the server are received by the client.

This setup previously worked without issues on a DigitalOcean server. I have now migrated to my own server located at home, where I have configured port forwarding for managing POST requests and serving content through Nginx. However, I have been unable to determine why the WebSocket communication is not functioning as expected.

I consistently receive a message indicating “received 1001 (going away) then sent 1001 (going away),” which corresponds to an exception on close. This occurs when the page is left or refreshed. While the client correctly displays the opening and closing of the connection, it does not receive any messages from the server.

SERVER CODE:

async def handler(websocket, path) :
    current = None
    print("handling something")
    try :
        async for message in websocket :
            parsedClientMessage = json.loads(message)
            print(parsedClientMessage)
            if parsedClientMessage["type"] == "01" :
                parsedClientData = (parsedClientMessage['message'])
                current = parsedClientData['username'] if type(parsedClientData) is dict and parsedClientData['username'] in Read(storage) else id(websocket)
                if not current in clients :
                    clients[current] = {}
                clients[current][id(websocket)] = websocket
        await websocket.send(["connect", "Welcome to TerminalSaturn!", id(websocket)])

    except Exception as e :
        print(e)
    finally: 
        print(f"closed connection")
        if current in clients :
            if len(clients[current]) - 1 == 0 :
                del clients[current] 
            else :
                del clients[current][id(websocket)] 



async def main() : 
    ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
    ssl_context.load_cert_chain(certfile=cert_path, keyfile=key_path)
    async with websockets.serve(ws_handler=handler, host='0.0.0.0',port=1111, ssl=ssl_context):
        print("WebSocket server is running with SSL/TLS")
        await asyncio.Future() 

CLIENT CODE:

const wsUrl = 'wss://REDACTED:1111';
const socket = new WebSocket(wsUrl);
export var SID = null


socket.onopen = function (event) {
    console.log(event)
    socket.send(JSON.stringify({ type: '01', message: utils.getUserData() }));
};

socket.onmessage = function (event) {
    const data = JSON.parse(event.data)
    console.log("got msgs")
    console.log(event.data)
    const operations = {
        "rload": () => {
            utils.generateNotification("Admin", "Your data was updated and your page will be automatically refreshed in 3 seconds.")
            setTimeout(() => {
                location.reload()
            }, 1000 * 3);
        },
        "connect": () => {
            console.log("connected")
            utils.generateNotification("Server", data[1])
            SID = data[2]
        },
        "dcl": () => {
            if (utils.getUserData()) {
                utils.logOut()
            }
        }
    }
    if (data[0] in operations) {
        operations[data[0]]()
    }
    else {
        utils.generateNotification("Server", data)
    }
};

I have verified that my certificate is functioning correctly, as I am using WSS, and POST requests with CORS are working without any issues on this certificate. I have also confirmed that there are no antivirus programs, firewalls, or other security measures interfering with the connection. Despite extensive research and troubleshooting efforts, I have been unable to resolve this issue. The only error code I encounter is 1001.