What did you do? If possible, provide a recipe for reproducing the error.
$server = new swoole_websocket_server('0.0.0.0', 4432, SWOOLE_BASE, SWOOLE_SOCK_TCP | SWOOLE_SSL);
$server->set([
'worker_num' => 1,
'pid_file' => __DIR__.'/Runtime/Websocket.pid',
'ssl_cert_file' => '#crt'
'ssl_key_file' => '#key'
'open_tcp_nodelay' => true,
'tcp_fastopen' => true,
'enable_reuse_port' => true,
'heartbeat_check_interval' => 10,
'heartbeat_idle_time' => 150
]);
$server->on('workerstart', function (swoole_websocket_server $server, $workerId) {
var_dump('workerstart');
});
$server->on('open', function (swoole_websocket_server $server, $request) {
var_dump('open');
});
$server->on('message', function (swoole_websocket_server $server, $request) {
var_dump('message');
});
$server->start();
What did you expect to see?
WebSocket 客户端无法成功连接服务端(相同代码在最近git pull之前可以正常运行), 去除SSL后也可以正常连接。
What did you see instead?
客户端使用WSS连接。
What version of Swoole are you using (php --ri swoole)?
swoole support => enabled
Version => 3.0.0-alpha
Author => tianfeng.han[email: mikan.tenny@gmail.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
openssl => enabled
http2 => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
What is your machine environment used (including version of kernel & php & gcc) ?
PHP 7.2.5 (cli) (built: May 16 2018 02:20:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[PHP Modules]
coordinate
Core
curl
date
hash
inotify
json
openssl
pcre
posix
Reflection
SPL
ssh2
standard
swoole
zlib
[Zend Modules]
CFLAGS="-O3 -g0 -I/usr/nghttp2/include" CXXFLAGS="-O3 -g0" LDFLAGS="-L/usr/nghttp2/lib" LIBS="-lnghttp2" ./configure --disable-all --enable-cli --disable-cgi --disable-phpdbg --enable-swoole-static --with-swoole --enable-timewheel --with-zlib=/usr/zlib --enable-openssl --with-openssl=/usr/openssl --with-ssh2=/usr/libssh2 --with-curl=/usr/curl --enable-http2 --enable-coordinate --enable-posix --enable-inotify --enable-hash --enable-json --enable-inline-optimization --with-config-file-path=/etc/php
WebSocket 客户端版本
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36
If you are using ssl, what is your openssl version?
openssl-1.1.0h