GatewayWorker创建wss服务

官方手册:http://doc2.workerman.net/326160

        // 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php
    $context = array(
        // 更多ssl选项请参考手册 http://php.net/manual/zh/context.ssl.php
        'ssl' => array(
            // 请使用绝对路径
            'local_cert'                 => 'C:\sll\1538629317020.pem', // 也可以是crt文件
            'local_pk'                   => 'C:\sll\1538629317020.key',
            'verify_peer'               => false,
            // 'allow_self_signed' => true, //如果是自签名证书需要开启此选项
        )
    );
    // websocket协议(端口任意,只要没有被其它程序占用就行)
    $gateway = new Gateway("websocket://0.0.0.0:8283", $context);
        // 开启SSL,websocket+SSL 即wss
    $gateway->transport = 'ssl';

然后前端链接WebSocket 前缀写上wss即可

安装GatewayWorker相关文章
https://blog.csdn.net/tdcqfyl/article/details/81170420
https://pasawu.top/article/10

Pasa吴技术博客
请先登录后发表评论
  • latest comments
  • 总共0条评论