Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client brukva connection #20

Open
burakdede opened this issue Dec 13, 2011 · 6 comments
Open

Client brukva connection #20

burakdede opened this issue Dec 13, 2011 · 6 comments

Comments

@burakdede
Copy link

class MessageUpdatesHandler(BaseHandler):
@tornado.web.authenticated
@tornado.web.asynchronous
def post(self):
    self.listing_id = self.get_argument("listing_id", None)
    self.cursor = self.get_argument("cursor", None)
    self.client = brukva.Client()
    self.client.connect()
    self.client.subscribe(self.listing_id)
    self.client.listen(self.on_new_messages)

def on_new_messages(self, messages):
    # Closed client connection
    if self.request.connection.stream.closed():
        return
    msg = json.loads(messages.body,'ascii')
    self.finish(dict(messages=[msg]))
    self.client.unsubscribe(self.listing_id)

def on_connection_close(self):
    # unsubscribe user from channel
    self.client.unsubscribe(self.listing_id)
    self.client.disconnect()

When I long poll using above code and check redis activity seems like when ever client send or posts something it creates new connection, so total connected client increasing on top of each other like 2 client talking and send 10 messages total connected client show 15 or sth like that. Is this bug or should I use different approach while connecting ?

@goldalworming
Copy link

what's your command in redis to monitor? I want to test it

@burakdede
Copy link
Author

I am not using any special command just checking the redis server output and as I see there are increasing number of client connected in evert post

@burakdede
Copy link
Author

@goldalworming did you find anything related to this problem ?

@goldalworming
Copy link

how do you paste your code in this commented system?

I couldn't paste it...

@goldalworming
Copy link

just see my repo https://github.com/goldalworming/tornado-redis-chat

I use 'monitor' in redis-cli and it works fine (only 2 subscribers)
but I got weird error. maybe you could solve it.

@burakdede
Copy link
Author

@goldalworming Yeah I do the same thing before but even its working it firing exception about "reading from non-existing connection" and try to listen channel its weird. And its probably related to this issue #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants