1

I have built a Websocket on Ubuntu 20.04 (LAMP) stack using Ratchet.

I followed this article https://www.twilio.com/blog/create-php-websocket-server-build-real-time-even-driven-application to build the websocket.

I Followed this article https://stackoverflow.com/questions/39336033/does-an-application-load-balancer-support-websockets to configure my webserver.

  1. Configured Security Group - Inbound rules TCP 8080
  2. Configured Load balancer
  3. Created Target group (TCP) for port 8080

enter image description here

  1. Enabled Stickyness (1 hour)
  2. SSL is configured and created in AWS Certificate Manager

enter image description here

  1. Apache configuration

    <VirtualHost *:80>
        ServerName chat.domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/websites/chat.domain.com/public
           <Directory /var/www/websites/chat.domain.com/public/>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Require all granted
           </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
        CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
    </VirtualHost>
    
    <VirtualHost *:443>
        ServerName chat.domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/websites/chat.domain.com/public
           <Directory /var/www/websites/chat.domain.com/public/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
            </Directory>
    
        ProxyPass / https://chat.domain.com:8080/
        ProxyPassReverse / https://chat.domain.com:8080/
        <Location "/">
            ProxyPass "wss://chat.domain.com:8080/"
        </Location>
    
    
        ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
        CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
    </VirtualHost>
    

Every thing is in place and running but I get

WebSocket connection to 'wss://chat.domain.com:8080/' failed:

Here is my chrome inspect

enter image description here

I have even tried to Open traffic to ALL ports (Inbound) just to check the security group but still getting the same error.

I doubt the problem is from configuring Load Balancer, Security Group and Target group?

Any help or suggestion?

1

Finally I found the solution.

  • The port 8080 should have been added to firewall
  • create a new target group for port 8080 which
  • create a load balancer with port http:8080 and point to the target group

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.