0

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>
9
  • I need someone to help me, give me attetion, I'm not able to do anything to solve it, 2 weeks trying to do something and nothing works, can you help? :( Commented Sep 10, 2020 at 23:51
  • Can an expert talk with me? I can pay money Commented Sep 11, 2020 at 0:12
  • Welcome to SF :) Be a bit patient, people who understand this area will see your question and reply if / when they can. It might take an hour or a day. Some things you can do to help is 1) Edit your firewall above to make them easier to understand - it doesn't say if that's iptables, security groups, network ACLs, or something else. You should link to a screen shot of each to make it obvious. 2) Add logs of your web server for the time matching the request, if if there's no matching log that's useful information.
    – Tim
    Commented Sep 11, 2020 at 1:35
  • 3) Do some basic diagnostics. Check that another EC2 instance in the same subnet / security group can access apache, both on port 80 with a standard page, and with a web socket. Gradually move the instance away from the main web server to test where the problem is. If the requests make it to Apache follow the chain of logs. 4) Make sure a basic https web page works before you try web sockets 5) Look at your VPC Flow logs to see if your requests are making it into your AWS network.
    – Tim
    Commented Sep 11, 2020 at 1:37
  • You could also make your question a bit more precise. eg " I used route 53 for routing" - Route53 is for DNS. "the website works perfectly with SSL" does that mean a simple page request over https works properly from outside AWS? I think the best way to solve this is a systematic process that works through the communication chain using application logs, VPC flow logs, etc
    – Tim
    Commented Sep 11, 2020 at 1:40

0

You must log in to answer this question.

Browse other questions tagged .