Search code examples
javascripthtmlwebwebsocketmixed-content

Using ws:// while on https:// (mixed content)


I have a html5 page with

var connection = new WebSocket('ws://foo.bar:8888');

But I get an error

Mixed Content: The page at 'https://foo.bar/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://foo.bar:8888/'. This request has been blocked; this endpoint must be available over WSS.

I understand that, but I can't serve a Secure Websocket. Is there any way to make this work, except starting chrome with --allow-running-insecure-content or something like that, where the user has to do something?

Thanks!


Solution

  • So months later I can say: If you can serve the page via https somewhere on your server there are certificate and chain files, use these to serve a wss