a view days ago i had my issius with websockets as well.
I tried to connect a websocket client with a websocket server.
"ws://..." works fine
var WebSocket = require('ws');
but "wss://..." don't.
As i added "protocolVersion" and "origin" at the second paramter as a object it works.
I thought about it and i maybe figured it out why first the websocket request were rejected.
As i know the client send a request "ws://" to the server asking for switching protocol from http to websocket over "http".
The server if able to speak websocketprotocol than switch the protocol so client and server now connected via websockets.
If the client send a secure-websocket request "wss://" to the server the client tries it with "https://" but the server can't solve this and reject the request, but if you specifie the origin as "http://" he can and will establish a websocket connection.
I wish that will help you, and please give feedback if so.
If i am wrong with my thoughts i'm happy to be enlightnend and like to get a hint! ;-)