AsyncTcpConnection 连接websocket,报以下错误
连接成功
SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
断开
$context = [
'ssl' => [
//是否需要验证 SSL 证书。
'verify_peer' => false,
'verify_peer_name' => false,
//是否允许自签名证书。
'allow_self_signed' => true,
],
];
$con = new AsyncTcpConnection('ws://streaming.forexpros.com:443/echo/958/fnzqglgx/websocket',$context);
$con->transport = 'ssl';
$con->onConnect = function ($con)
{
echo '连接成功'.PHP_EOL;
};
$con->onMessage = function ($con, $msg)
{
};
$con->onClose = function ($con)
{
echo '断开';
};
$con->connect();
连接成功
SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
断开
服务器系统:CentOS release 6.9 (Final)
php版本:php8.2
workerMan版本:4.1.11
服务端证书有问题
用js可以正常连接
php自带的stream_socket_enable_crypto 函数不认你的证书
证书问题,要么重签,要么试着升级下OpenSSL