https服务报错 Warning: stream_socket_enable_crypto()

lcchongzi

代码如下

<?php
require_once __DIR__ . '/Autoloader.php';
use Workerman\Worker;

// 证书最好是申请的证书
$context = array(
    'ssl' => array(
        'local_cert'  => '/etc/apache2/ssl/2_www.XXXX.cn.crt',
        'local_pk'    => '/etc/apache2/ssl/3_www.XXXXcn.key',
        'verify_peer' => false,
    )
);
// 这里设置的是websocket协议,也可以http协议或者其它协议
$worker = new Worker('http://www.XXXXXX.cn:5765', $context);
// 设置transport开启ssl
$worker->transport = 'ssl';
$worker->onMessage = function($con, $msg) {
    $con->send('ok');
    var_dump($msg);
};

Worker::runAll();

php -m 查看也开启了 openssl 开启服务后控制台:收到

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request in /var/www/workerman/Connection/TcpConnection.php on line 567

SSL Handshake fail. 
Buffer:312e310d0a486f73743a203133392e3139362e33392e3138333a353930300d0a436f6e6e656374696f6e3a206b6565702d616c6976650d0a43616368652d436f6e74726f6c3a206d61782d6167653d300d0a557067726164652d496e7365637572652d52657175657374733a20310d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e5420362e313b2057696e36343b2078363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f35382e302e333032392e313130205361666172692f3533372e33360d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c696d6167652f776562702c2a2f2a3b713d302e380d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174652c20736463680d0a4163636570742d4c616e67756167653a207a682d434e2c7a683b713d302e382c656e3b713d302e362c64613b713d302e340d0a0d0a^CWorkerman stopping ...

请问是什么原因,哪位朋友遇到过?

12010 1 0
1个回答

walkor 打赏

说明有客户端用
http://www.XXXXXX.cn:5765
访问了这个地址

应该用
https://www.XXXXXX.cn:5765
访问才对

  • 暂无评论
年代过于久远,无法发表回答
×
🔝