2

由于我的网站使用 https,我似乎无法连接棘轮。我什至安装了stunnel。这是我的配置

演示:https ://usyd.chat/react.html (见源代码和控制台)

推送服务器.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();

这是我连接到我的网络套接字的方式

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

最后,我的 stunnel 配置

output = /etc/stunnel/stunnel.log

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

当我在控制台上的 react.html 页面上没有任何反应。在我的推手课上,我有

echo "connected"

在 onOpen 方法中,但它不会在控制台中记录任何内容。

非常感激任何的帮助。谢谢

4

1 回答 1

0

看看这个类似问题的答案:https ://stackoverflow.com/a/47200806/3777134

现在您不需要 stunnel 或代理,您可以使用 React\Socket\SecureServer 类直接处理来自 Ratchet 服务器的安全连接。

于 2017-11-15T09:57:11.707 回答