尝试连接SockJs server。我从安全的 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 = function(e) {console.log('[.] message' + e.data);};
sockjs.onclose = function() {console.log('[*] close');};
我得到SecurityError: The operation is insecure.
,然后又回到openxhr-polling
如果我从 http http://localhost/index.php
运行它,则建立websocket连接。
是否无法从安全页面创建不安全的websocket?
更新这种情况发生在Firefox中,但在Chrome中我可以打开websocket
更新2 最终我使用https服务器解决了这个问题。 See here.