繁体   English   中英

PHP Websocket 错误:net::ERR_SSL_PROTOCOL_ERROR 使用 cloudflare

[英]PHP Websocket ERROR: net::ERR_SSL_PROTOCOL_ERROR using cloudflare

到目前为止,我已经在 SSL 上工作了 PHP 棘轮 Websocket。 最近,我在我的网站上设置了 cloudflare。 这样做之后,我在客户端收到一个错误: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR 正如我所检查的,后端的 websocket 服务器确实在工作并等待建立连接。

这里是前端websocket建立: const conn = new WebSocket('wss://xyz:8080');

这是我的 websocket 服务器设置:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/vendor/autoload.php';

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use dealspace_websocket\Chat;

$app = new HttpServer(
    new WsServer(
        new Chat()
    )
);

$loop = \React\EventLoop\Factory::create();

$privateKEY = __DIR__ . '/../private/private.pem';
$publicKEY = __DIR__ . '/../private/public.pem';
$secure_websockets = new \React\Socket\Server('0.0.0.0:8080', $loop);
$secure_websockets = new \React\Socket\SecureServer($secure_websockets, $loop, [
    'local_cert' => $publicKEY,
    'local_pk' => $privateKEY,
    'verify_peer' => false
]);

$secure_websockets_server = new \Ratchet\Server\IoServer($app, $secure_websockets, $loop);
$secure_websockets_server->run();

?>

我还在服务器中启用了错误,但在运行服务器时我没有得到任何错误。

If your server use a proxy with Cloudflare, the secure Websocket can only use a HTTPS port supported by Cloudflare: https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-Cloudflare-与-一起工作

  • 443
  • 2053
  • 2083
  • 2087
  • 2096
  • 8443

如果您的域的流量发往与上面列出的端口不同的端口,则可以:通过 Cloudflare DNS 应用程序将子域添加为灰色云记录,或启用 Cloudflare Spectrum。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM