gpt4 book ai didi

amazon-web-services - 配置 Ratchet 和 EC2 以及 AWS 负载均衡器将 WebSocket 连接抛出到 'wss://chat.domain.com:8080/' 失败

转载 作者:行者123 更新时间:2023-12-04 16:14:15 25 4
gpt4 key购买 nike

我已经使用 Ratchet 在 Ubuntu 20.04 (LAMP) 堆栈上构建了一个 Websocket。
我关注了这篇文章https://www.twilio.com/blog/create-php-websocket-server-build-real-time-even-driven-application构建 websocket。
我关注了这篇文章 Does an Application Load Balancer support WebSockets?配置我的网络服务器。

  • 配置的安全组 - 入站规则 TCP 8080
  • 配置的负载均衡器
  • 为端口 8080 创建目标组 (TCP)

  • enter image description here
  • 启用粘性(1 小时)
  • 在 AWS 证书管理器中配置和创建 SSL

  • enter image description here
  • Apache 配置
    <VirtualHost *:80>
    ServerName chat.domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/websites/chat.domain.com/public
    <Directory /var/www/websites/chat.domain.com/public/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
    CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
    </VirtualHost>

    <VirtualHost *:443>
    ServerName chat.domain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/websites/chat.domain.com/public
    <Directory /var/www/websites/chat.domain.com/public/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
    </Directory>

    ProxyPass / https://chat.domain.com:8080/
    ProxyPassReverse / https://chat.domain.com:8080/
    <Location "/">
    ProxyPass "wss://chat.domain.com:8080/"
    </Location>


    ErrorLog ${APACHE_LOG_DIR}/chat.domain.com/error.log
    CustomLog ${APACHE_LOG_DIR}/chat.domain.com/access.log combined
    </VirtualHost>

  • 一切都到位并运行,但我得到

    WebSocket connection to 'wss://chat.domain.com:8080/' failed:


    这是我的 chrome 检查
    enter image description here
    我什至尝试打开所有端口(Inbond)的流量只是为了检查安全组,但仍然遇到相同的错误。
    我怀疑问题是配置负载均衡器、安全组和目标组?
    任何帮助或建议?

    最佳答案

    最后我找到了解决方案。端口 8080 应该已添加到防火墙,我必须为端口 8080 创建一个新的目标组,然后我必须创建一个带有端口 http:8080 的负载均衡器并指向目标组。

    关于amazon-web-services - 配置 Ratchet 和 EC2 以及 AWS 负载均衡器将 WebSocket 连接抛出到 'wss://chat.domain.com:8080/' 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68133541/

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