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

时光总嘲笑我的痴心妄想 提交于 2021-02-07 04:36:12

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/43768161/using-ws-while-on-https-mixed-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!