我在Python中創建了一個websockets服務器(based in this gist),它在localhost中工作,但不在生產服務器中工作。Websockets握手問題
例如,在本地主機我有以下握手的消息:
//Message from webbrowser client
GET/HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Host: 127.0.0.1:8080
Origin: null
Sec-WebSocket-Key1: ]2 415 401 032v
Sec-WebSocket-Key2: 2y7 9Y2o 80049 5
Cookie: (...)
t��t`��
//Response of server
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: null
WebSocket-Location: ws://127.0.0.1:8080/
Sec-Websocket-Origin: null
Sec-Websocket-Location: ws://127.0.0.1:8080/
�@2�J��[email protected]��ƶ
當我運行相同webssocket在生產服務器,連接失敗。 「WebSocket的握手期間錯誤:‘連接’標題值不是‘升級’」在Chrome的控制檯我得到下面的錯誤 - 但在握手的服務器和客戶端(從服務器)連接具有正確的價值之間的消息:
//Message from webbrowser client
GET/HTTP/1.0
Host: myserver.com
X-Forwarded-Host: myserver.com
X-Forwarded-Server: myserver.com
X-Forwarded-For: 189.6.133.224
Connection: close
Upgrade: WebSocket
Origin: http://myserver.com
Sec-WebSocket-Key1: 2 1)Gz 11919la 978
Sec-WebSocket-Key2: c94Q6b9^ef#`6 2v {652
Cookie: (...)
//Response of server
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Origin: http://myserver.com
WebSocket-Location: ws://myserver.com/websocket/server
Sec-Websocket-Origin: http://myserver.com
Sec-Websocket-Location: ws://myserver.com/websocket/server
yz�~�r}��+�4J
在生產中我得到了客戶的郵件中的某些陌生人值:
- 哪裏是在消息的最後瘋狂代碼?
- 'Connection'標題的值是'close'?!
有人知道爲什麼我得到這個錯誤,爲什麼客戶端握手有這些值?