现在我的网站使用 https,我似乎无法连接棘轮。我什至安装了隧道。这是我的配置
演示: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();
以下是我连接到 Web 套接字的方式
var conn = new ab.Session('wss://usyd.chat:8080')
最后,我的隧道配置
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 方法中也是如此,但它不会在控制台中记录任何内容。
任何帮助将不胜感激。谢谢
看看这个类似问题的答案:https://stackoverflow.com/a/47200806/3777134
现在你不需要stunnel或代理,你可以使用React''Socket''SecureServer类直接从Ratchet服务器处理安全连接。