Я пытаюсь получить пример hello-world из документации по веб-сокетам торнадо. Я довольно новичок в торнадо, и совершенно новый для веб-сокетов. Я указал следующий обработчик прямо из документов:
class EchoWebSocket(tornado.websocket.WebSocketHandler):
def open(self):
print "WebSocket opened"
def on_message(self, message):
self.write_message(u"You said: " + message)
def on_close(self):
print "WebSocket closed"
и вызовите его из javascript, используя
var ws = new WebSocket("ws://localhost:6665/websocket");
ws.onopen = function() {
ws.send("Hello, world");
};
ws.onmessage = function (evt) {
alert(evt.data);
};
также прямо из документов. Я сразу ударил три исключения:
[E 111123 17:45:54 iostream:233] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 iostream:221] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 ioloop:281] Exception in I/O handler for fd 4
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/ioloop.py", line 269, in start
self._handlers[fd](fd, events)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
что я признаюсь в неспособности разобрать должным образом, и я нервничаю, чтобы окунуться в tornado.web. Есть что-то очевидное, что я делаю не так? Я использую торнадо 1.2.1.