Answers: <p>Finally I found the solution.</p>
  <ul>
  <li>The port 8080 should have been added to firewall</li>
  <li>create a new target group for port 8080 which</li>
  <li>create a load balancer with port http:8080 and point to the target group</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2021-08-02T09:13:48.440Z
Answers: 2021-08-11T20:24:08.323Z
Answers: 2021-08-11T20:24:08.323Z
Answers: Fury
Body: <p>I have built a Websocket on Ubuntu 20.04 (LAMP) stack using Ratchet.</p>
  <p>I followed this article <a href="https://www.twilio.com/blog/create-php-websocket-server-build-real-time-even-driven-application" rel="nofollow noreferrer">https://www.twilio.com/blog/create-php-websocket-server-build-real-time-even-driven-application</a> to build the websocket.</p>
  <p>I Followed this article <a href="https://stackoverflow.com/questions/39336033/does-an-application-load-balancer-support-websockets">https://stackoverflow.com/questions/39336033/does-an-application-load-balancer-support-websockets</a> to configure my webserver.</p>
  <ol>
  <li>Configured Security Group - Inbound rules  TCP  8080</li>
  <li>Configured Load balancer</li>
  <li>Created Target group (TCP) for port 8080</li>
  </ol>
  <p><a href="https://i.sstatic.net/Ii4GX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ii4GX.png" alt="enter image description here" /></a></p>
  <ol start="4">
  <li>Enabled Stickyness (1 hour)</li>
  <li>SSL is configured and created in AWS Certificate Manager</li>
  </ol>
  <p><a href="https://i.sstatic.net/Kl32a.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Kl32a.png" alt="enter image description here" /></a></p>
  <ol start="5">
  <li><p>Apache configuration</p>
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName chat.domain.com
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/websites/chat.domain.com/public
         &lt;Directory /var/www/websites/chat.domain.com/public/&gt;
             Options Indexes FollowSymLinks MultiViews
             AllowOverride All
             Require all granted
         &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
      CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:443&gt;
      ServerName chat.domain.com
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www/websites/chat.domain.com/public
         &lt;Directory /var/www/websites/chat.domain.com/public/&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
          &lt;/Directory&gt;
  
      ProxyPass / https://chat.domain.com:8080/
      ProxyPassReverse / https://chat.domain.com:8080/
      &lt;Location &quot;/&quot;&gt;
          ProxyPass &quot;wss://chat.domain.com:8080/&quot;
      &lt;/Location&gt;
  
  
      ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
      CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  </li>
  </ol>
  <p>Every thing is in place and running but I get</p>
  <blockquote>
  <p>WebSocket connection to 'wss://chat.domain.com:8080/' failed:</p>
  </blockquote>
  <p>Here is my chrome inspect</p>
  <p><a href="https://i.sstatic.net/2bvIJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2bvIJ.png" alt="enter image description here" /></a></p>
  <p>I have even tried to Open traffic to ALL ports (Inbound) just to check the security group but still getting the same error.</p>
  <p>I doubt the problem is from configuring Load Balancer, Security Group and Target group?</p>
  <p>Any help or suggestion?</p>
  
Tags: <amazon-web-services>
Title: Configure WebSocket on AWS EC2 Load Balancer throws Connection to 'wss://chat.domain.com:8080/' failed
UserDisplayName: Fury
ThreadText: # Configure WebSocket on AWS EC2 Load Balancer throws Connection to 'wss://chat.domain.com:8080/' failed
  
  (Asked by: username_0 on 2021-07-01)
  
  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](https://i.sstatic.net/Ii4GX.png)](https://i.sstatic.net/Ii4GX.png)
  
  4. Enabled Stickyness (1 hour)
  5. SSL is configured and created in AWS Certificate Manager
  
  [![enter image description here](https://i.sstatic.net/Kl32a.png)](https://i.sstatic.net/Kl32a.png)
  
  5. 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](https://i.sstatic.net/2bvIJ.png)](https://i.sstatic.net/2bvIJ.png)
  
  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?
  
  **Tags:** amazon-web-services
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-08-02. Score: 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
  
  
  ---
  
  