Ratchet WSS Websocket Error: Let's make it works!

For those who are using Ratchet and encountered these errors using "wss" protocol, here is the easiest fix!

Before we start, just make sure that you enable these modules on your Apache configuration (httpd.conf)

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule ssl_module modules/mod_ssl.so

# Put this line on your Apache's httpd.conf
ProxyRequests off
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass /wss2/ ws://yourdomain.com:8080
# End of line

Then restart your Apache.

. . . .

Now on your ratchet php file change the port to "8080"


$server = IoServer::factory(new HttpServer(new WsServer(new Chat)), 8080);

btw, you can use any port as long as it is not being used by other application

On your Javascript file, do something like this

var conn = new WebSocket('wss://yourdomain.com/wss2/');

Then run your Ratchet php file.

It should work now! :)

Did you like the post? Help the author stay up! any amount will be a great help :) Just click the link below