1

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.
Janier
  • 3,982
  • 9
  • 43
  • 96
  • 1
    I would guess that you don't have sticky load balancing. You could configure the client to always start with webSocket and avoid the socket.io initial HTTP polling that requires sticky load balancing in order to work properly. See [Socket.io 1.x: use WebSockets only](https://stackoverflow.com/questions/28238628/socket-io-1-x-use-websockets-only/28240802#28240802) for details. – jfriend00 Dec 03 '17 at 02:36
  • That helped.Now its only websocket calls.But stil the problem exists. It tried WSS and it fails. WebSocket connection to 'wss://www.myurl.ca/socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established. – Janier Dec 03 '17 at 06:23
  • 1
    Then there's something wrong with either your https credentials or your https socket.io server code or your AWS setup for https. We can't do any more than make wild guesses without seeing more code and detail. – jfriend00 Dec 03 '17 at 06:30

1 Answers1

0

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.

Janier
  • 3,982
  • 9
  • 43
  • 96