leporo / tornado-redis

Asynchronous Redis client that works within Tornado IO loop.
667 stars 163 forks source link

Weird error when integrating with SockJS #47

Closed chemary closed 10 years ago

chemary commented 10 years ago

Hi, I'm in early stages of using tornado/redis/sockjs so maybe the error is mine or placed on the incorrect place, sorry.

I implemented the example on https://github.com/leporo/tornado-redis/blob/master/demos/sockjs/app.py

I always get next traceback when I disconnect, I added function calls from classes MessageHandler and SockJSSubscriber.

MessageHandler:__init__()
SockJSSubscriber:on_message()
MessageHandler:on_close
SockJSSubscriber:unsubscribe()

ERROR:tornado.application:Uncaught exception POST /subscribe/782/5es5waak/xhr_streaming (127.0.0.1)
HTTPRequest(protocol='http', host='127.0.0.1:8889', method='POST', uri='/subscribe/782/5es5waak/xhr_streaming', version='HTTP/1.0', remote_ip='127.0.0.1', headers={'Origin': 'http://testtornado.oonair.net', 'Content-Length': '0', 'Accept-Language': 'en-US,en;q=0.8,es;q=0.6,ca;q=0.4', 'Accept-Encoding': 'gzip,deflate,sdch', 'X-Forwarded-Host': 'testtornado.oonair.net', 'Host': '127.0.0.1:8889', 'Accept': '*/*', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1678.0 Safari/537.36', 'Connection': 'close', 'Referer': 'http://testtornado.oonair.net/index.html', 'X-Real-Ip': '192.168.0.135', 'Cookie': '__utma=65992624.1844703960.1382547828.1382547828.1382547828.1; __utmc=65992624; __utmz=65992624.1382547828.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); JSESSIONID=dummy'})
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1115, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 302, in wrapped
    ret = fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 550, in inner
    self.set_result(key, result)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 476, in set_result
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 507, in run
    yielded = self.gen.send(next)
  File "/usr/local/lib/python2.7/dist-packages/tornadoredis/client.py", line 1106, in listen
    self.on_unsubscribed([result.channel])
  File "/usr/local/lib/python2.7/dist-packages/tornadoredis/client.py", line 1013, in on_unsubscribed
    self.subscribed.remove(channel)
KeyError: u'test_channel'
leporo commented 10 years ago

Thank you, I fixed this. Please update a package and confirm that it solves the issue. Feel free to ask me if you need any assistance.

chemary commented 10 years ago

sorry for not replying before, I updated the code and now it works, thanks.