swoole 配置 ssl 使用

问题描述

http 页面请求 websocket ,可以正常请求。但在 https 页面请求 websocket 却报下边这样的错误:

failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

现场环境

websocket 服务端使用的 swoole,编译时,也带上了 --enable-openssl,执行 php --ri swoole 时,结果如下:

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.3.1
Built => Apr  1 2019 17:09:22
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
http2 => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

页面 js请求也换成了 wssssl 证书也添加了。请问有小伙伴遇到过这样的问题么。可有解决方法。谢谢。

直播间 熊猫血 虚幻之物对应着冥冥之路!
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1

我被自己给坑了。
我只做了这个操作就好了

$this->server = new swoole_websocket_server(config('swoole.host'), config('swoole.port')); 

## 改为
$this->server = new swoole_websocket_server(config('swoole.host'), config('swoole.port'), SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL);
5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!