我想通過pywebsocket的幫助讓WebSocket在Apache服務器上運行。 服務器現在已經安裝好了,我可以通過Chrome做一個Websocket連接。但是,當我試圖通過Safari建立連接時,我得到一個「意外的響應代碼:404」,並且它看起來不能與服務器建立WebSocket連接。WebSockets:讓Safari與pywebsockets一起工作Apache擴展
任何指針在這裏將不勝感激。下面是我正在調用的客戶端JS代碼,用於建立連接以及safari頭標記與Chrome頭標記。
function connect() {
if ('WebSocket' in window) {
socket = new WebSocket("ws://localhost/mystream");
} else if ('MozWebSocket' in window) {
socket = new MozWebSocket("ws://localhost/mystream");
} else {
return;
}
socket.onopen = function() {
showResult('Opened');
};
socket.onmessage = function (event) {
showResult(event.data);
};
socket.onerror = function() {
showResult('Error in connection');
};
socket.onclose = function (event) {
var logMessage = 'Closed (';
if ((arguments.length == 1) && ('CloseEvent' in window) && (event instanceof CloseEvent)) {
logMessage += 'wasClean = ' + event.wasClean;
if ('code' in event) {
logMessage += ', code = ' + event.code;
}
if ('reason' in event) {
logMessage += ', reason = ' + event.reason;
}
} else {
logMessage += 'CloseEvent is not available';
}
showResult(logMessage + ')');
};
showResult('Successfully Connected ');
}
野生動物園頭:
Origin: http://192.168.1.8
Sec-WebSocket-Key1: 26 ~ 5 75G3 36< 0 U8T
Connection: Upgrade
Host: localhost
Sec-WebSocket-Key2: 1<A 9 4 4l865P5/6L5
Upgrade: WebSocket
鉻頭:
Connection:Upgrade
Host:localhost
Origin:http://192.168.1.8
Sec-WebSocket-Key:IAkX9XGWsCZHPQepzYjwxA==
Sec-WebSocket-Version:13
Upgrade:websocket
(Key3):00:00:00:00:00:00:00:00
根據pywebsockets網站上的文檔,Hixie-76似乎在websocket協議實現列表中得到支持。 – baradas 2011-12-15 02:53:39