Ratchet icon indicating copy to clipboard operation
Ratchet copied to clipboard

Ratchet with route, SSL and OriginsCheck

Open anytrack-software opened this issue 8 years ago • 2 comments

I already configured the ratchet to use SSL with ReatPHP and OriginsCheck and saw that it is possible to work routes. Only in the examples says to use the Ratchet \ App, how would this setting be using what I already have?

<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\Http\OriginCheck;
use Ratchet\WebSocket\WsServer;
use React\Socket\SecureServer;
use React\Socket\Server;
use React\EventLoop\Factory;

require dirname(__DIR__) . '/vendor/autoload.php';
require __DIR__ . '/Chat.php';

$allowed_origins = array(
    'chat.local',
);

$loop = Factory::create();

$ws = new WsServer(new Chat($loop));
$ws->enableKeepAlive($loop);

$checkOrigin = new OriginCheck($ws, $allowed_origins);

$http = new HttpServer($checkOrigin);
$webSock = new Server('0.0.0.0:8443', $loop);
$socketServer = new SecureServer(
    $webSock,
    $loop,
    [
        'local_cert' => 'C:\xampp2\apache\conf\ssl.crt\server.crt',
        'local_pk' => 'C:\xampp2\apache\conf\ssl.key\server.key',
        'allow_self_signed' => true,
        'verify_peer' => false
     ]
);
$server = new IoServer($http, $socketServer,$loop);
$server->run();

anytrack-software avatar Sep 17 '18 15:09 anytrack-software

@douglasnoronha - The Router can be wrapped by HttpServer.

mbonneau avatar Dec 14 '18 02:12 mbonneau

Hey! Thanks for reporting this issue 🙏

We're giving Ratchet some much-needed love and attention! As part of our issue cleanup initiative (#1100), we're reviewing and closing issues that look like they might already be resolved.

If this is still relevant to you, we'd love to continue this conversation in our GitHub Discussions. Just reference this issue when you post. If you want to support Ratchet, please consider sponsoring our work! ❤️

PaulRotmann avatar May 28 '25 15:05 PaulRotmann