在文件\application\push\command\Workerman.php中,將startGateWay和startBusinessWorker中增加支持SSL證書即可,參考配置:
private function startBusinessWorker()
{
$context = array(
'ssl' => array(
'local_cert' => ROOT_PATH . '/cert/證書PEM.pem',
'local_pk' => ROOT_PATH . '/cert/證書KEY.key',
'verify_peer' => false,
)
);
// bussinessWorker 進程
$worker = new BusinessWorker('', $context);
// worker名稱
$worker->name = $this->config['chat']['name'];
// bussinessWorker進程數(shù)量
$worker->count = $this->config['chat']['count'];
//設(shè)置處理業(yè)務(wù)的類,此處制定Events的命名空間
$worker->eventHandler = \app\push\controller\Events::class;
// 服務(wù)注冊地址
$worker->registerAddress = $this->config['channel']['ip'] . ':' . $this->config['channel']['port'];
$worker->transport = 'ssl';
}
private function startGateWay()
{
$context = array(
'ssl' => array(
'local_cert' => ROOT_PATH . '/cert/證書PEM.pem',
'local_pk' => ROOT_PATH . '/cert/證書KEY.key',
'verify_peer' => false,
)
);
$gateway = new Gateway($this->config['chat']['protocol'] . "://" . $this->config['chat']['ip'] . ":" . $this->config['chat']['port'], $context);
$gateway->name = $this->config['chat']['name'];
// gateway進程數(shù)
$gateway->count = $this->config['chat']['count'];
$gateway->startPort = 2900;
// 服務(wù)注冊地址
$gateway->registerAddress = $this->config['channel']['ip'] . ':' . $this->config['channel']['port'];
$gateway->transport = 'ssl';
}
修改前端訪問格式為:wss即可。
可自行參考是否使用哦!