I really need help with websockets, recently I used SSL(Let's Encrypt) in my website that is in ec2, and I used route 53 for routing, and the website works perfectly with SSL and my DNS, but I can't start connection with WebSockets and HTTPS, it only works with HTTP, using the port 8080, when I try to start connection with HTTPS under port 8443, Google console says:
WebSocket connection to "mysite" failed: WebSocket opening handshake timed out
I really don't know what to do anymore, in my point of view everything is okay with the part of coding but it really looks like a problem involving Apache and SSL, please help me, I'm with this problem there are 2 weeks and I don't know what to do
AWS:
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 ✔
PHP:
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use Anne\Socket\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8433
);
$server->run();
JS:
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
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>