node.js - NodeJs Socket 部署在 AWS LoadBalancer 上不起作用
问题描述
我的 NodeJs Socket.io 在 HTTP 上运行良好,但是一旦我将实例添加到 AWS 负载均衡器并通过 HTTPS 访问它,它确实会连接一次,但之后它会一直断开连接。通过 Socket,我实现了聊天 - 所以只有一次双向通信发生,然后我得到错误记录“一个套接字与服务器断开连接”。以下是我的 AWS 配置
从客户端(Android),我正在使用
https://example.com
和来自 NodeJs NGINX 的日志
2021/11/13 16:58:58 [error] 21285#21285: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.27.33, server: , request: "GET /socket.io/?EIO=4&transport=polling HTTP/1.1", upstream: "http://127.0.0.1:8080/socket.io/?EIO=4&transport=polling", host: "domain.com"
2021/11/13 17:24:49 [error] 22100#22100: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.27.33, server: , request: "POST /socket.io/?EIO=4&transport=polling&sid=xLc-Bz_iYKAXXXXXX- HTTP/1.1", upstream: "http://127.0.0.1:8080/socket.io/?EIO=4&transport=polling&sid=xLc-Bz_iYKXXXXXX-", host: "doman.com"
解决方案
推荐阅读
- uwamp - Curl 模块未在 UWAMP 和 Windows 10 上加载?
- c# - C# WinForms 应用程序意外退出,无异常,但仅当 API 块不在同一台机器上时
- kubernetes - kubeadm v1.18.2 和 crio 版本 1.18.2 无法从 Centos7 / RH7 上的私有仓库启动主节点
- python - 我应该使用 Qt 信号还是事件?
- r - 在 readODS::read_ods 中指定 col_types
- vue.js - 使用 vueJS 限制 v-for 的结果
- node.js - Node.js,从不同的文件访问打字稿静态变量
- arrays - 在现有项目中保存大型类数组的最佳和最快方法是什么?领域不工作
- google-bigquery - 项目的 BigQuery 费用
- php - 在 Apache Web 服务器上用 PHP 编写的 API 返回 php 代码本身