python tornado tornado.application: Uncaught exception get -


i try have none blocking websocket in python. choosed tornado.

i succeed creating connection , sending data in first place. when tried server non-blocking error:

error:tornado.application:uncaught exception / (127.0.0.1) 

httpserverrequest(protocol='http', host='127.0.0.1:9000', method='get', uri='/', version='http/1.1', remote_ip='127.0.0.1', headers={'origin': 'file://', 'connection': 'upgrade', 'sec-websocket-key': 'g2a4/0/5xf0vyzpm7yz5ya==', 'host': '127.0.0.1:9000', 'cache-control': 'no-cache', 'sec-websocket-version': '13', 'pragma': 'no-cache', 'accept-language': 'en-us,en;q=0.8,de-de;q=0.6,de;q=0.4', 'accept-encoding': 'gzip, deflate, sdch, br', 'user-agent': 'mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/56.0.2924.87 safari/537.36', 'upgrade': 'websocket', 'sec-websocket-extensions': 'permessage-deflate; client_max_window_bits'}) traceback (most recent call last): file "/usr/lib/python3/dist-packages/tornado/web.py", line 1369, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) file "", line 3, in raise_exc_info file "/usr/lib/python3/dist-packages/tornado/stack_context.py", line 314, in wrapped ret = fn(*args, **kwargs) file "/usr/lib/python3/dist-packages/tornado/web.py", line 1583, in future_complete self.finish() file "/usr/lib/python3/dist-packages/tornado/websocket.py", line 391, in _disallow_for_websocket raise runtimeerror("method not supported web sockets") runtimeerror: method not supported web sockets

and here source code:

from concurrent.futures import threadpoolexecutor  import time import tornado.websocket import tornado.queues import tornado.web tornado.gen import coroutine, return   class socket(tornado.websocket.websockethandler):     def initialize(self, message_listeners):         self._thread_pool = threadpoolexecutor(10)         self.queue = tornado.queues.queue()         self.message_listeners = message_listeners  @coroutine def worker(self, msg):     # need send other server,blocking here     time.sleep(10)     raise return(msg)  def open(self):     # send known states init  @tornado.web.asynchronous @coroutine def on_message(self, message):     self.queue.put(message)  def on_close(self):     print("websocket connection closed")  def check_origin(self, origin):     return true  def send(self, message):     self.write_message(message)  @coroutine def loop(self):     print("in loop")     while true:         msg = yield self.queue.get()         if msg none:             return         pmessage = yield self.worker(msg)         self.send(pmessage) 

main:

    port=7004     application = tornado.web.application([         (r'/', websocket_connection.socket,         dict(message_listeners=self.message_listeners)), ])  http_server = tornado.httpserver.httpserver(application) http_server.listen(port) 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -