wss 龙卷风连接问题 [英] wss tornado connection issues
问题描述
龙卷风服务器
ssl_options = {
"certfile": "server.crt",
"keyfile": "server.key"
}
application=Application()
server=tornado.httpserver.HTTPServer(application,xheaders=True,ssl_options=ssl_options)
server.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.instance().start()
JS Websocket
JS Websocket
webSocket = new WebSocket("wss://" + location.hostname + ":8888/socket");
没有打开连接,也没有调用open()方法,也没有报错.
The connection does not open, and the open() method is not called, and there is no error either.
尝试使用来自 JS 的不安全套接字连接时
When trying with an insecure socket connection from JS
webSocket = new WebSocket("ws://" + location.hostname + ":8888/socket");
我收到以下错误:
Tornado:
[W 140725 11:35:35 iostream:845] SSL Error on 11 ('192.168.0.72', 54554): [Errno 1] _ssl.c:504: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
JS:
WebSocket connection to 'ws://192.168.0.72:8888/socket' failed: Connection closed before receiving a handshake response
但是,当我从 tornado 中删除 ssl_options 并尝试从 JS 建立不安全的连接时,它工作正常.
However when I remove the ssl_options from tornado, and try and insecure connection from JS, it works fine.
Tornado:
server = tornado.httpserver.HTTPServer(application)
JS:
webSocket = new WebSocket("ws://" + location.hostname + ":8888/socket");
我无法弄清楚可能是什么问题以及如何继续.
I am unable to figure out what the issue might be and how to proceed.
推荐答案
tornado 错误消息意味着 http 请求正在发送到 https 端口.我正在从 http url 加载 javascript,将其更改为 https 解决了问题.
The tornado error message means that an http request is being sent to an https port. I was loading the javascript from an http url, changing that to https solved the problem.
这篇关于wss 龙卷风连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!