2015-09-06 87 views
1

當連接到我的WebSocket時,在客戶端連接之後,出現上述錯誤。「WebSocket握手期間出錯:狀態行無效」

2015-09-06 12:01:12-0400 [-] reactor class: twisted.internet.epollreactor.EPollReactor. 
2015-09-06 12:01:12-0400 [-] ServerFactory starting on 1025 
2015-09-06 12:01:12-0400 [-] Starting factory <twisted.internet.protocol.ServerFactory instance at 0x1f92f80> 
2015-09-06 12:01:28-0400 [-] Got new client! 
2015-09-06 12:01:28-0400 [-] received 'GET/HTTP/1.1' 
2015-09-06 12:01:28-0400 [-] received 'Host: ip:1025' 
2015-09-06 12:01:28-0400 [-] received 'Connection: Upgrade' 
2015-09-06 12:01:28-0400 [-] received 'Pragma: no-cache' 
2015-09-06 12:01:28-0400 [-] received 'Cache-Control: no-cache' 
2015-09-06 12:01:28-0400 [-] received 'Upgrade: websocket' 
2015-09-06 12:01:28-0400 [-] received 'Origin: http://server-ip.net' 
2015-09-06 12:01:28-0400 [-] received 'Sec-WebSocket-Version: 13' 
2015-09-06 12:01:28-0400 [-] received 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36' 
2015-09-06 12:01:28-0400 [-] received 'Accept-Encoding: gzip, deflate, sdch' 
2015-09-06 12:01:28-0400 [-] received 'Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4' 
2015-09-06 12:01:28-0400 [-] received 'Sec-WebSocket-Key: Au1JIvJG0A2Jep3+wqCPRg==' 
2015-09-06 12:01:28-0400 [-] received 'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits' 
2015-09-06 12:01:28-0400 [-] received '' 
2015-09-06 12:01:28-0400 [-] Lost a client! 

在客戶端,它看起來像這樣:

WebSocket connection to 'ws://server-ip:1025/' failed: Error during WebSocket handshake: Invalid status line

我一直在努力做的事情:

我跟着this tutorial創建一個即時聊天(Django的)。我使用的chatserver.py直接來自他們的文檔:https://twistedmatrix.com/documents/current/_downloads/chatserver.py。其餘的(jQuery腳本等)就像在那個教程中一樣。

回答

1

MyChat.lineReceived將消息發送給每個連接的客戶端,包括本身。我期望這意味着它會將所收到的所有頭文件回傳給WebSocket客戶端,這可能不是它所期望的。

您鏈接到的ferritfarmer教程通過將該MyChat的工廠包裝到WebsocketResource中進行處理,該修改從chatserver.py直接鏈接到正常的Twisted示例。

我相信WebsocketResource來自Twisted教程鏈接的特定開發分支。不幸的是,分支似乎停滯不前。我聽到Autobahn的WebSocket實現是一個很好的地方。

相關問題