the current situation is that port 7999 of tornado is running two app, and one http protocol and one websocket protocol, all of which are normal on localhost, but on the server, websocket cannot shake hands successfully. Do you have any relevant experience in timeout, directly?
Front end code:
//weosocket
initWebSocket(){
if(this.websocket === null || this.websocket === undefined){
const config = require("../../../config");
const endpoint = location.hostname + ":" + config.dev.endport;
const wsuri = "ws://"+ endpoint + "/connect"
this.websocket = new WebSocket(wsuri);
this.websocket.onopen = this.websocketonopen;
this.websocket.onerror = this.websocketonerror;
this.websocket.onmessage = this.websocketonmessage;
this.websocket.onclose = this.websocketclose;
}
},
websocketonopen() {
console.log("WebSocket");
},
backend code:
if __name__ == "__main__":
tornado.options.define("port", default=7999, help="run on the given port", type=int)
tornado.options.parse_command_line(sys.argv)
flask_wsgi_app = tornado.wsgi.WSGIContainer(app)
mixed_app = tornado.web.Application([
("/connect", ConnectionHandler),
(".*", tornado.web.FallbackHandler, dict(fallback=flask_wsgi_app))
])
http_server = tornado.httpserver.HTTPServer(mixed_app)
http_server.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.instance().start()