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 证书也添加了。请问有小伙伴遇到过这样的问题么。可有解决方法。谢谢。

直播间 熊猫血 虚幻之物对应着冥冥之路!
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 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年前 评论

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