SockJs-尝试从安全页面创建不安全的websocket连接时出错
正在尝试连接到。我正在从一个安全的https页面SockJs-尝试从安全页面创建不安全的websocket连接时出错,websocket,sockjs,Websocket,Sockjs,正在尝试连接到。我正在从一个安全的https页面https://localhost/index.php var sockjs_url = 'http://localhost:9999/echo'; var sockjs = new SockJS(sockjs_url); sockjs.onopen = function() {console.log('[*] open' + sockjs.protocol);}; sockjs.onmessage = f
https://localhost/index.php
var sockjs_url = 'http://localhost:9999/echo';
var sockjs = new SockJS(sockjs_url);
sockjs.onopen = function() {console.log('[*] open' + sockjs.protocol);};
sockjs.onmessage = function(e) {console.log('[.] message' + e.data);};
sockjs.onclose = function() {console.log('[*] close');};
我得到了SecurityError:操作不安全。
并且它返回到openxhr轮询
如果我从http运行它http://localhost/index.php
websocket连接已建立
无法从安全页面创建不安全的websocket吗
更新这在Firefox中发生,但在Chrome中我可以打开websocket
更新2最终我通过使用https服务器解决了这个问题
更新3相关一些浏览器禁止从安全页面运行不安全的WebSocket连接