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


Listen 80

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


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


use RatchetServerIoServer;
use RatchetHttpHttpServer;
use RatchetWebSocketWsServer;
use AnneSocketChat;

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

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


AWS Security Groups:

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

Google Console:

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