2

I can't seem to connect ratchet now that my website uses https. I even have stunnel installed. Here is my configuration

Demo: https://usyd.chat/react.html (see source code and console)

push-server.php

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

$loop   = React\EventLoop\Factory::create();
$pusher = new Unichat\Pusher;

// Listen for the web server to make a ZeroMQ push after an ajax request
$context = new React\ZMQ\Context($loop);
$pull = $context->getSocket(ZMQ::SOCKET_PULL);
$pull->bind('tcp://103.4.16.217:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself
$pull->on('message', array($pusher, 'onInterfere'));

// Set up our WebSocket server for clients wanting real-time updates
$webSock = new React\Socket\Server($loop);
$webSock->listen(8080, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect
$webServer = new Ratchet\Server\IoServer(
    new Ratchet\Http\HttpServer(
        new Ratchet\WebSocket\WsServer(
            new Ratchet\Wamp\WampServer(
                $pusher
            )
        )
    ),
    $webSock
);

$loop->run();

Here is how I'm connecting to my web socket

var conn = new ab.Session('wss://usyd.chat:8080')

Finally, my stunnel config

output = /etc/stunnel/stunnel.log

[websockets]
#cert = /etc/ssl/crt/primary.crt
cert = /etc/stunnel/stunnel.pem
accept = 8443
connect = 8080

Nothing happens when I go on the react.html page on the console. In my pusher class, i have

echo "connected"

in the onOpen method too but it doesn't log anything in the console.

Any help would be most appreciated. Thanks

fatffatable
  • 399
  • 3
  • 11

1 Answers1

0

Take a look at this answer to a similar question: https://stackoverflow.com/a/47200806/3777134

Now you don't need stunnel or a proxy, you can directly handle the secure connexion from the Ratchet server using the React\Socket\SecureServer class.

Jordi
  • 1,108
  • 1
  • 8
  • 18