gpt4 book ai didi

java - 使用rest服务器和websocket与elasticbeanstalk,java,无法连接

转载 作者:行者123 更新时间:2023-12-02 08:44:56 24 4
gpt4 key购买 nike

我正在尝试将 nginx 路由配置为能够使用 Rest 服务器(使用 Java Spark)和 Websockets(使用 Netty-socketIO)。

它在本地运行得很好,但无法在 aws elasticbeanstalk 上运行。

我有 Java Spark 监听端口 5000,这是 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html 的默认端口

By default, Elastic Beanstalk configures the nginx proxy to forward requests to your application on port 5000

这样就可以了。

我在端口 9000 上监听 Websocket。我确实将ELB协议(protocol)更改为TCP。

仍然来自 aws 文档:

To extend Elastic Beanstalk's default nginx configuration, add .conf configuration files to a folder named .ebextensions/nginx/conf.d/ in your application source bundle. Elastic Beanstalk's nginx configuration includes .conf files in this folder automatically.

我尝试过但没有取得太大成功:

server {
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

SocketIO-客户端连接字符串http://beanstalk-address-here.us-east-1.elasticbeanstalk.com:9000

在“网络”选项卡中,请求在失败之前会(待处理)一段时间。

最佳答案

一个可能的问题是您没有正确配置 ELB 以排除端口 9000 上的连接。您必须正确配置 ELB 上的安全组以允许非标准端口上的连接:

https://aws.amazon.com/premiumsupport/knowledge-center/elb-connectivity-troubleshooting/

关于java - 使用rest服务器和websocket与elasticbeanstalk,java,无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43190535/

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