Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ratchet with route, SSL and OriginsCheck #686

Open
douglasnoronha opened this issue Sep 17, 2018 · 1 comment
Open

Ratchet with route, SSL and OriginsCheck #686

douglasnoronha opened this issue Sep 17, 2018 · 1 comment
Labels

Comments

@douglasnoronha
Copy link

douglasnoronha commented Sep 17, 2018

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();
@mbonneau
Copy link
Member

@douglasnoronha - The Router can be wrapped by HttpServer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants