【发布时间】:2013-03-31 00:32:44
【问题描述】:
尝试连接到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.
更新 3 相关 Firefox Websocket security issue
【问题讨论】: