ratchet_client icon indicating copy to clipboard operation
ratchet_client copied to clipboard

WSS support

Open TravisCornelius opened this issue 5 years ago • 4 comments

How many beers do I need to buy you for wss support?

TravisCornelius avatar Aug 26 '19 21:08 TravisCornelius

Hi @TravisCornelius

The lib actually supports WSS, you juste have to configure reverse proxy on your apache or nginx server

Thanks

romainrg avatar Oct 16 '19 08:10 romainrg

Hi, what exactly can I explain about using https and wss?

asfshop avatar Oct 26 '19 14:10 asfshop

I can't use wss

I have the valid certificate on the host location I'm running ratchet with the host configuration tls: //0.0.0.0 but I have this javascript error message

"WebSocket connection to 'wss://0.0.0.0:8080/' failed: Error in connection establishment: net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH"

Thanks in advance for your help

rocooliveira avatar Dec 30 '19 14:12 rocooliveira

If you want to use the current lib with WSS, you have to use a reverse proxy to tunnel the wss connection to ws, like e.g. here.

The included React and Ratchet libraries however do support WSS, so you only have to adjust the run() method of the Ratchet_client class to something like this:

$app = new \Ratchet\Http\HttpServer(
	new \Ratchet\WebSocket\WsServer(
		new Server()
	)
);

$loop = \React\EventLoop\Factory::create();

$secure_websockets = new \React\Socket\Server($this->host . ':' . $this->port, $loop);
$secure_websockets = new \React\Socket\SecureServer($secure_websockets, $loop, [
	'local_cert' => '/path/to/server.crt',
	'local_pk' => '/path/to/server.key',
	'allow_self_signed' => TRUE, // allow self signed certs, should be false in production
	'verify_peer' => FALSE
]);

$secure_websockets_server = new \Ratchet\Server\IoServer($app, $secure_websockets, $loop);
$secure_websockets_server->run();

ludis avatar May 11 '20 19:05 ludis