远程或在我的服务器(不是代理)上运行websocket服务器

时间:2020-07-13 18:51:21

标签: php websocket ratchet

所以这里说http://socketo.me/docs/troubleshooting

“如果要打开Ratchet(不在代理后面),请将App的第三个参数设置为'0.0.0.0'。”

我在这里(/vendor/cboden/ratchet/src/Ratchet/App.php):

     /**
     * @param string        $httpHost HTTP hostname clients intend to connect to. MUST match JS `new WebSocket('ws://$httpHost');`
     * @param int           $port     Port to listen on. If 80, assuming production, Flash on 843 otherwise expecting Flash to be proxied through 8843
     * @param string        $address  IP address to bind to. Default is localhost/proxy only. '0.0.0.0' for any machine.
     * @param LoopInterface $loop     Specific React\EventLoop to bind the application to. null will create one for you.
     */   
    public function __construct($httpHost = '47.243.247.244', $port = 8180, $address = '0.0.0.0', LoopInterface $loop = null) {

这是我的客户端:

var websocket_server = new WebSocket("ws://47.243.247.244:8180/");

这是websocket服务器:

$server = IoServer::factory(
    new HttpServer(new WsServer(new Chat())),
    8180
);

我的问题是我无法在客户端连接。你能纠正我我做错了什么吗?我在Intrenet中进行了搜索,但找不到清晰的答案。而且,请不要告诉我如何使用代理。 (为安全起见,我向您显示了我网站的其他IP地址)

0 个答案:

没有答案