gpt4 book ai didi

ssl - 到 'wss://test.example.com:8090/' 的 WebSocket 连接失败 : WebSocket opening handshake timed out

转载 作者:太空宇宙 更新时间:2023-11-03 15:08:53 25 4
gpt4 key购买 nike

我正在为 Laravel 项目使用 https 和 websocket 连接。我已经设置了虚拟主机,如下所示:

<VirtualHost *:80>
ServerName test.example.com
ServerAdmin test.example.com
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>

ServerAdmin test.example.com
ServerName test.example.com

SSLEngine on
SSLCertificateFile "cert.pem"
SSLCertificateKeyFile "privkey.pem"
SSLCertificateChainFile "chain.pem"

SSLProxyEngine On
ProxyPreserveHost On
ProxyRequests Off

ProxyPass /wss wss://test.example.com:8090/
ProxyPassReverse /wss wss://test.example.com:8090/

DocumentRoot "/var/www/html/laravel/public"
<Directory "/var/www/html/laravel/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Require all granted
</Directory>
</VirtualHost>

但它在浏览器中显示错误:
   WebSocket connection to 'wss://test.example.com:8090/' failed: WebSocket opening handshake timed out

你能帮我们解决什么问题吗?

提前致谢

最佳答案

如果您使用 laravel 库 cboden/ratchet 作为套接字
然后转到 app/Console/Commands/WebSocketServer.php
用这些代码行替换 handle 函数并使用您的认证文件路径“local_cert”和“local_pk”

public function handle()
{

$loop = Factory::create();
$webSock = new SecureServer(
new Server('0.0.0.0:8090', $loop),
$loop,
array(
'local_cert' => '/opt/ssl/chamberstock_com.crt', // path to your cert
'local_pk' => '/opt/ssl/server.key', // path to your server private key
'allow_self_signed' => TRUE, // Allow self signed certs (should be false in production)
'verify_peer' => FALSE
)
);
// Ratchet magic
$webServer = new IoServer(
new HttpServer(
new WsServer(
new WebSocketController()
)
),
$webSock
);
$loop->run();

}

关于ssl - 到 'wss://test.example.com:8090/' 的 WebSocket 连接失败 : WebSocket opening handshake timed out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54231572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com