WebSocket握手失败

时间:2016-07-01 14:14:24

标签: amazon-web-services spring-websocket

我的应用程序是一个Spring引导应用程序,它使用Spring WebSocket和STOMP。所有配置在我当地都运行良好。但是在云中获得以下错误。

服务器错误: -

  

ERROR o.s.w.s.s.s.DefaultHandshakeHandler - 由于握手失败   无效的升级标题:null

客户端错误: - 在浏览器中: -

  

WebSocket连接到   ' WSS://.example.com/ws/313/7pq61a2c/websocket'失败:   WebSocket握手期间出错:意外的响应代码:400

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>
<dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-messaging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
        </dependency>

我使用ELB部署在AWS云中。我的实例在HTTP上运行,并在ELB中启用了HTTPS。我将AWS route 53用于我的域名。

我添加了一个&#39; A&#39;使用路由53中的LoadBalancer URL进行记录。

HTTPS证书适用于* .example.com。

ELB配置如下

  

HTTP - 80 - HTTP - 80

     

HTTPS - 443 - HTTP - 80

我做谷歌搜索,发现我需要增加空闲超时。用户可以将会话保持打开8小时。 那么,我需要配置它8个小时吗? 是否应该在ELB中进行任何其他配置?

虽然我们在HTTP上运行我们的EC2实例,但我们有一个过滤器,它根据X-Forward_Proto标题将用户重定向回HTTPS。

在调试日志日志中,我看到http://example.com:80/ws/313/7pq61a2c/websocket

这可能是原因吗?

如何配置websocket以尝试使用https而非http?

由于

1 个答案:

答案 0 :(得分:0)

我认为问题是AWS ELB目前不支持Web套接字。

您可以查看以下链接:

  1. https://blog.jverkamp.com/2015/07/20/configuring-websockets-behind-an-aws-elb/
  2. https://www.built.io/blog/2014/11/websockets-on-aws-elb/
  3. 希望这有帮助。

相关问题