You cannot switch from unencrypted (ws) to encrypted (wss) in the same socket connection. You can establish two connections from the very beginning and simply do not use encrypted until you are ready if you are concerned about the installation delay. Otherwise, just create a new encrypted session when you are ready.
source
share