2015-05-16 148 views
0

我試圖運行使用https和安全websockets(wss://)的聊天應用程序,並且出現以下錯誤。我正在使用我創建的自簽名證書。如果我從chrome桌面訪問我的site,它可以工作。如果我從Chrome ios訪問同一網站,則會收到以下錯誤消息。另外,從Chrome ios,我得到了不可信證書的警告並接受它。所以我想讓它適用於Chrome ios。python tornado SSLEOFError:EOF發生違反協議(_ssl.c:581)

[E 150516 14:01:56 http1connection:700] Uncaught exception 
Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/dist-packages/tornado/http1connection.py", line 691, in _server_request_loop 
    ret = yield conn.read_response(request_delegate) 
    File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 807, in run 
    value = future.result() 
    File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 209, in result 
    raise_exc_info(self._exc_info) 
    File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 810, in run 
    yielded = self.gen.throw(*sys.exc_info()) 
    File "/usr/local/lib/python2.7/dist-packages/tornado/http1connection.py", line 166, in _read_message 
    quiet_exceptions=iostream.StreamClosedError) 
    File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 807, in run 
    value = future.result() 
    File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 209, in result 
    raise_exc_info(self._exc_info) 
    File "<string>", line 3, in raise_exc_info 
SSLEOFError: EOF occurred in violation of protocol (_ssl.c:581) 

這裏是我的代碼

import tornado.ioloop 
import tornado.web 
import tornado.options 
import tornado.httpserver 
import os 
import tornado.websocket 

import ssl 
ssl.PROTOCOL_SSLv23 = ssl.PROTOCOL_TLSv1 

clients = [] 

class IndexHandler(tornado.web.RequestHandler): 
    @tornado.web.asynchronous 
    def get(request): 
    request.render("index.html") 

class WebSocketChatHandler(tornado.websocket.WebSocketHandler): 
    def open(self, *args): 
    print("open", "WebSocketChatHandler") 
    clients.append(self) 

    def on_message(self, message):   
    print message 
    for client in clients: 
     client.write_message(message) 

    def on_close(self): 
    clients.remove(self) 

application = tornado.web.Application([(r'/wschat', WebSocketChatHandler), (r'/', IndexHandler)]) 

data_dir = '/home/bob' 

#http_server = tornado.httpserver.HTTPServer(application) 
http_server = tornado.httpserver.HTTPServer(application, ssl_options={ 
    "certfile": os.path.join(data_dir, "myselfsigned.cer"), 
    "keyfile": os.path.join(data_dir, "myselfsigned.key"), 
}) 

if __name__ == "__main__": 
    tornado.options.parse_command_line() 
    http_server.listen(443) 
    tornado.ioloop.IOLoop.instance().start() 

我跑蟒蛇2.7.9,和龍捲風4.1。我懷疑我必須猴子補丁龍捲風,但我已經嘗試過各種猴子補丁,並沒有成功。有人可以幫助我修補猴子龍捲風,或者詳細說明如何解決這個問題。另外,我是SSL新手,所以請向我解釋,就像我5歲那樣:)

非常感謝您的時間和耐心!

回答

相關問題