0

I have a problem involving WebSockets, well, I have a website, and recently I put SSL on it, using Let's Encrypt, okay, SSL works perfectly, along with my website that is hosted on EC2, with a domain that I bought on Route 53, however, I am facing a problem when trying to establish a connection with WebSockets, I have a chat that uses the PHP Ratchet library, and by default I used port 8080 to establish a connection between server and client, however, as I am using SSL, port 8080 it will not take effect, that said, I tried to use several ports, 8443, 8080, 3000, 8181, 8282, 4433, and none of them really work, because the Google console reports failed: WebSocket opening handshake timed out error. Well, I don't really know if the problem is with the server or the client, I think it is with the client, since the php script runs perfectly, but does not accept connections. I've also enabled all these ports that I mentioned, in the security group of my EC2 machine, but the error persists, well, is this a problem involving Let's Encrypt? Should I edit an SSL file to establish connections via WebSocket? Or should I edit httpd.conf? I really don't know what to do, I believe everything is fine with my code, however, nothing works Incidentally, now when I try to use port 8443, the PHP script says that the port is already in use, and I've already tried to stop this process that is running, using the command fuser -k 8443/tcp, but the process doesn't stop, well, the only alternative port to use with SSL is 8443? Is there any other door? If not, how do I stop the process in which the door is running I really need help, I'm a beginner and for me this becomes something very complex, because I always try a new thing and it always goes wrong

JS:

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

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()
            )
         ),
        4433
    );

    $server->run();

Google Console:

WebSocket connection to "mysite" failed: WebSocket opening handshake timed out

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 ✔
3
  • Should I create a new EC2 instance?
    – AnneReb
    Commented Sep 6, 2020 at 13:47
  • A timeout usually points toward a firewall instance. Your security groups look good, but check if you have an additional firewall on your instance. Commented Sep 6, 2020 at 13:59
  • Welcome Anne. A tip, if you break up your question into sentences and paragraphs it's easier for people to read, and you'll get more help. A new EC2 instance probably won't help, you need to look at security groups, NACLs, instance firewalls, maybe routing.
    – Tim
    Commented Sep 6, 2020 at 19:31

0

You must log in to answer this question.

Browse other questions tagged .