使用wss进行连接
1,创建服务器连接:
$this->server = new \Swoole\WebSocket\Server($serverConf['host'], $serverConf['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL);
2.$this->server->set($serverConf['setting']);中设置配置内容:
'setting' => [
'worker_num' => 6,
"daemonize"=> 0, //守护进程
'log_file' => '/www/wwwroot/www.baidu.com/mytest/runtime.log' ,
'max_wait_time' => 60,
'document_root' => '/www/wwwroot/www.baidu.com/mytest/',
'enable_static_handler'=> true,
"static_handler_locations" => ['/File'],
'reload_async' => true, //开启热重载
'enable_coroutine' => true, //开启协程容器
//'task_worker_num' => 4, // 设置 task 进程数量
//'task_enable_coroutine' => true, // 启用 task 进程的协程支持
'package_max_length'=> 1024*1024*20, //数据包最大长度
'ssl_cert_file' => '/www/wwwroot/ssl2/pub.pem',
'ssl_key_file' => '/www/wwwroot/ssl2/pri.pem',
]
3.pub.pem和pri.pem分别为申请的公私有证书内容;