I'm working on Live chat project of Ratchet (http://socketo.me/) in Laravel. Everything is working fine for me but after installing SSL certificate on my domain, websocket not connecting with websocket server. I built cpanel with WHM on dedicated server by myself and install require modules.
My server.php file code to run on server port is,
$server = IoServer::factory(
new HttpServer(
new WsServer(
new ChatSocket()
)
),
8080
);
$server->run();
My ChatSocket Class in which all of the code runs, save and retrieve data is,
class ChatSocket implements MessageComponentInterface {
protected $clients;
public function __construct() {
$this->clients = new \SplObjectStorage;
}
public function onOpen(ConnectionInterface $conn) {
//store the new connection
$this->clients->attach($conn);
echo "someone connected
";
}
public function onMessage(ConnectionInterface $from, $msg) {
//send the message to all the other clients except the one who sent.
foreach ($this->clients as $client) {
if ($from !== $client) {
$client->send($msg);
}
}
}
public function onClose(ConnectionInterface $conn) {
$this->clients->detach($conn);
echo "someone has disconnected";
}
public function onError(ConnectionInterface $conn, \Exception $e) {
echo "An error has occurred: {$e->getMessage()}
";
$conn->close();
}
}
when I try to connect with http like the code below, it's working fine for me.
var conn = new WebSocket('ws://mydomain.com:8080');
but when I implement SSL certificate and change ws:// to wss:// then it's not working for me like below,
var conn = new WebSocket('wss://mydomain.com:8080');
I search out on this platform as well and try many solutions to make it run, set ProxyPass on server and try to connect with ProxyPass by placing below code in httpd.conf file of the server but It's also not working for me. I loaded modules for ProxyPass as well,
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
ServerName www.mydomain.com
ProxyRequests On
ProxyVia On
ProxyPass /_ws_ ws://mydomain.com:8080
ProxyPassReverse /_ws_ ws://mydomain.com:8080
</IfModule>
</IfModule>
After adding this I restarted httpd file and restart full server as well to confirm that apache server is restarted.
Please help me to get connected with websocket with SSL.
My Questions are,