Search code examples
amazon-web-serviceshttpswebsocketamazon-elastic-beanstalkelastic-load-balancer

socket io not working with https ;switching back to polling


I have Node.JS app running in Elastic Bean Stalk. I have Elastic Load Balancer set up and SSL is set up in that.

I did socket.io in my Node.JS. I had trouble accessing it because of Nginx configurations. I fixed them by using .ebextensions .

Now when i access my socket io using my HTTP URL , it works good and it uses WebSocket protocol itself. But When i use HTTPS, it switches back to polling. How can i fix this?

Is it some configuration I have to do to make it work in HTTPS?

Update : After adding {transports: ['websocket'], upgrade: false} ,its sending only websokcet requests. But still I get error as

WebSocket connection to 'wss://myurl.ca/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established.

Solution

  • The problem was with certificates.HTTPS certificates were set up for www.myurl.ca .And websocket calls were without www . It was just wss://myurl.ca.

    It was a minor mistake.But changing the certificate to myurl.ca solved the issue.