AnswerBun.com

I can't start connection with WebSockets in EC2

Server Fault Asked by Paula Silva on December 21, 2020

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

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>

Add your own answers!

Related Questions

Enabling jumbo frame on tg3

0  Asked on December 15, 2020 by gli-illuminati

     

Postfix does not retry after 451 error / greylisting

2  Asked on December 14, 2020 by assylias

       

OpenVPN over dynamic IPv6

1  Asked on December 14, 2020 by hellstorm

   

autossh does not kill ssh when link down

1  Asked on December 13, 2020

   

Is it safe to write batch files with Unix line endings?

4  Asked on December 13, 2020 by cmcginty

   

On demand new IPv6 using privacy extension?

1  Asked on December 12, 2020 by wannabecoder

         

nginx, gitlab, subdomain

1  Asked on December 10, 2020 by emidee

       

Move Access 2016 Database to Azure?

0  Asked on December 9, 2020 by user601108

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir