PHP棘手麻烦SSL

时间:2016-02-24 03:35:54

标签: php ratchet stunnel

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

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

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();

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

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方法中也是

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

任何帮助都将非常感激。 感谢

1 个答案:

答案 0 :(得分:0)

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

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