简体   繁体   English

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

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

By now, I had working PHP Ratchet Websocket over SSL.到目前为止,我已经在 SSL 上工作了 PHP 棘轮 Websocket。 Lately, I've set up cloudflare in my website.最近,我在我的网站上设置了 cloudflare。 After doing so, I get an error in client side: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR .这样做之后,我在客户端收到一个错误: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR As I check, The websocket server, in the backend, is indeed working and waiting for connections to be established.正如我所检查的,后端的 websocket 服务器确实在工作并等待建立连接。

Here is the fornt-end websocket establishment: const conn = new WebSocket('wss://xyz:8080');这里是前端websocket建立: const conn = new WebSocket('wss://xyz:8080');

And here is my websocket server set up:这是我的 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();

?> ?>

I've also enabled errors in the server, but I don't get any when running the server.我还在服务器中启用了错误,但在运行服务器时我没有得到任何错误。

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-work-with- 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 443
  • 2053 2053
  • 2083 2083
  • 2087 2087
  • 2096 2096
  • 8443 8443

If traffic for your domain is destined for a different port than listed above, either: Add the subdomain as a gray-clouded record via your Cloudflare DNS app, or Enable Cloudflare Spectrum.如果您的域的流量发往与上面列出的端口不同的端口,则可以:通过 Cloudflare DNS 应用程序将子域添加为灰色云记录,或启用 Cloudflare Spectrum。

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

相关问题 连接建立错误:尝试建立并连接到Websocket服务器时,抛出net :: ERR_SSL_PROTOCOL_ERROR - Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server socket.io 错误网络::ERR_SSL_PROTOCOL_ERROR - socket.io error net::ERR_SSL_PROTOCOL_ERROR 如何处理net :: ERR_SSL_PROTOCOL_ERROR? - How to deal with net::ERR_SSL_PROTOCOL_ERROR? 在 react js 中使用新闻 api 时加载资源失败:net::ERR_SSL_PROTOCOL_ERROR - Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR while using news api in react js Wordpress - 错误 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL 协议错误 - Wordpress - Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error 跨域请求的间歇性 ERR_SSL_PROTOCOL_ERROR 错误 - Intermittent ERR_SSL_PROTOCOL_ERROR error for cross domain request POST https://localhost:5000/stored net::ERR_SSL_PROTOCOL_ERROR - POST https://localhost:5000/stored net::ERR_SSL_PROTOCOL_ERROR 访问不同端口时,js fetch 失败并出现 net::ERR_SSL_PROTOCOL_ERROR - js fetch fails with net::ERR_SSL_PROTOCOL_ERROR when accessing different ports Javascript / jQuery HTML5 视频 - catch net::ERR_SSL_PROTOCOL_ERROR with listener - Javascript / jQuery HTML5 Video - catch net::ERR_SSL_PROTOCOL_ERROR with listener 如何修复由我的 js 代码引起的 net::ERR_SSL_PROTOCOL_ERROR - How do I fix net::ERR_SSL_PROTOCOL_ERROR caused by my js code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM