Unable to connect Websocket in Production

Viewed 41

I am using PHP, Ratchet to connect Websocket. It's working perfectly on localhost but in production nothing happens. Even its not showing any error in console. Also this request is remains pending in Chrome Dev Tools.

Note - Websocket will be run only on specific url(https://mydomain.in/Chatboat/chatrequest).

Already started these services -

a2enmod proxy
a2enmod proxy_http
a2enmod proxy_wstunnel

Sharing My code-

$(document).ready(function() {
        var conn = new WebSocket('wss://mydomain.in:8888/');
        conn.onopen = function(event) {
            console.log('Connection Established');
        }; 
});

Apache Configuration -

<IfModule mod_ssl.c>
<VirtualHost *:443 *:8888>
      ServerName mydomain.in
      ServerAdmin mydomain.in
        DocumentRoot /var/www/html/projectfolder

        <Directory /var/www/html/projectfolder/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full
    <Proxy *>
        Require all granted
    </Proxy>

ProxyPassMatch ^/(Chatboat/chatrequest)$  ws://mydomain.in:8888/$1
ProxyPass / https://mydomain.in:8888/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://mydomain.in:8888/$1" [P,L]

</VirtualHost>
</IfModule>
0 Answers
Related