websocket server host has to be blank in order to

2019-08-04 04:52发布

问题:

I have an aws application load balancer with an https listener on port 9999, forwarding to a group on port 9999 with an ec2-instance being the target.

If I run my websocket server with the host name configured to my domain api.example.com, then when the client tries to open a websocket connection it gets:

Error during WebSocket handshake: Unexpected response code: 502

However, if I configure my websocket server with an empty string instead of the domain, then it connects just fine!

This is problematic because the server I am intending to run on this instance automatically launches a websocket server ONLY IF there is a websocket host name configuration provided, so a blank string means the websocket server will never launch! I would prefer to not have to hack the library to get around that condition. So I am wondering, why in the world a blank string works, but the domain name does not?

I tried localhost, the ip of the box, etc, everything results in a 502 except a blank string!