由于我的网站使用 https,我似乎无法连接 Ratchet 。我什至有隧道安装。这是我的配置
演示: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 页面时,没有任何 react 。在我的推手课上,我有
echo "connected"
在 onOpen 方法中也是如此,但它不会在控制台中记录任何内容。
非常感激任何的帮助。
谢谢
最佳答案
看看这个对类似问题的回答:https://stackoverflow.com/a/47200806/3777134
现在您不需要 stunnel 或代理,您可以使用 React\Socket\SecureServer 类直接处理来自 Ratchet 服务器的安全连接。
关于SSL 的 PHP Ratchet 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35592754/