php – Can’t connect to WebSocket using Ratchet + SSL in EC2 with Apache


I recently put my site on the air using EC2 + RDS, and I chose to get the Let’s Encrypt certificate, however, I have an error because of the SSL certificate.

I have an online chat that uses the PHP Ratchet library for websockets connections, but when trying to start the server over SSL, I am not successful, well, when I run the script, it works perfectly, but when I open the browser, the console Google says connection time is up
What happens is that the server runs perfectly on both the server and the client using HTTP, without SSL, but that’s not what I want, because I want secure traffic on my site, I’ve tried using multiple ports, but none of them works, only port 8080 with HTTP, with SSL does not work at all
I have already edited the security groups on AWS, I don’t think this is something to consider, as the ports are already available in the security group, I think as this is happening because of SSL, so I should change some SSL file or Apache to accept websockets connections via SSL?
Please help me, I’m a beginner and I don’t know what else to do, I’ve been having this problem for over a week, I’ve been posting on StackOverflow but no one really can help me, I’m lost, I don’t know what to do, I need to some professional to help me, or else it will become a tiring and impossible task for me

Apache:

Listen 80

    <VirtualHost *:80>
        DocumentRoot "/var/www/html"
        ServerName "example.com"
        ServerAlias "www.example.com"
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.example.com (OR)
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} (END,NE,R=permanent)
    
    ProxyPreserveHost On
    
    ProxyPass /chat.php/ ws://example.com:8433/
    ProxyPassReverse /chat.php/ ws://example.com:8433/
    </VirtualHost>

JavaScript:

var conn = new WebSocket('wss://example.com:8433/chat.php'); //Using port 8433, it doesn't works as any port, I already tried a lot of ports

PHP:

<?php
use RatchetServerIoServer;
use RatchetHttpHttpServer;
use RatchetWebSocketWsServer;
use AnneSocketChat;

    require dirname(__DIR__) . '/vendor/autoload.php';

    $server = IoServer::factory(
        new HttpServer(
            new WsServer(
                new Chat()
            )
         ),
        8433
    );

    $server->run();

AWS Security Groups:

Ports   Protocol    Source  SecurityGroup
80  tcp 0.0.0.0/0, ::/0 ✔
8080    tcp 0.0.0.0/0, ::/0 ✔
4433    tcp 0.0.0.0/0, ::/0 ✔
22  tcp 0.0.0.0/0   ✔
8443    tcp 0.0.0.0/0, ::/0 ✔
3000    tcp 0.0.0.0/0   ✔
443 tcp 0.0.0.0/0, ::/0 ✔

Google Console:

WebSocket connection to “mysite” failed: WebSocket opening handshake
timed out