use window.location.protocol to decide between ws: and wss: