i recently started to face this problem on chrome,where i am not able to connect to a websocket which is hosted under a different domain.
Example use case:
consider a domain that is front-ended by load balancer -> lb.com with two datacenters -> lb-dc1 and lb-dc2.The application page is hosted from lb.com but the code in this page, will create a web socket connection to lb-dc1 or lb-dc2.
This works fine on firefox/safari, but this connection is failing on chrome.
You can also see this behavior one
https://www.websocket.org/echo.html
Where the test socket connection will fail on chrome (i am using latest 91.0 version) whereas it will work on firefox.
I have an nginx proxy to pass the WSS request.. it looks something like this
location /socket {
proxy_pass http://<my-service>:8080/socket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_buffering off;
proxy_ignore_client_abort off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_read_timeout 86400;
break;
}