Elastic Beanstalk stripping Sec-WebSocket-Accept h

2019-05-15 07:24发布

I'm trying to get a .NET Core application running on elastic beanstalk to receive websockets connections from javascript in the browser.

When I test my client and server outside AWS on my local machine I am able to establish a websocket connection betwen the two. But when I deploy the server to elastic beanstalk I get the following error

WebSocket connection to 'ws://52.62.253.144/' failed: Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing

The server replies with a 101 Switching Protocols, so I know the server is trying to establish the connection, but the Sec-WebSocket-Accept header is missing. When testing locally, this header is present.

Is it possible elastic beanstalk is stripping the Sec-WebSocket-Accept from the response? It is currently configured in a 'Single Instance' scenario, not autoscaling.

Thanks in advance

2条回答
冷血范
2楼-- · 2019-05-15 07:57

Same thing happened to me in a Tomcat/Java project, it was finally fixed by switching the ELB protocols to TCP/SSL. The official documentation shows you how to switch them, can you try this and let me know.

查看更多
不美不萌又怎样
3楼-- · 2019-05-15 08:02

AWS do not accept unserscores(_) in headders, while we can use (-), So Remove underscores from the header variables, example:- header_var_val = "some value" replace it with headervarval = "some value". It works for me.

查看更多
登录 后发表回答