2013-04-08 51 views
3

嘗試連接到SockJs server。我從一個安全的HTTPS 頁面https://localhost/index.phpSockJs - 嘗試從安全頁面創建不安全websocket連接的錯誤

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?

UPDATE這發生在Firefox,但在Chrome我能夠打開的WebSocket

更新2最後,我通過使用HTTPS服務器解決它。 See here.

更新3個相關Firefox Websocket security issue

回答

0

有些瀏覽器禁止運行安全網頁中的不安全WebSocket連接,including FireFox.