![](/img/trans.png)
[英]Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server
[英]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-與-一起工作
如果您的域的流量發往與上面列出的端口不同的端口,則可以:通過 Cloudflare DNS 應用程序將子域添加為灰色雲記錄,或啟用 Cloudflare Spectrum。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.