Relevant minimal code needed to understand the issue:
In the browser:
var url = "wss://" + "www.example.com" + "