Archived
This forum has been archived. Please start a new discussion on GitHub.
Glacier2.Applicaiton and Redis client listening for Redis events
Hi,
I've used Glacier2.Application class in my python client ( on linux ). The problem is that the client reports connection lost from time to time.
Please, have a look at the code. Note the monitor_queue function which, if I'm not mistaken, contains blocking code of a redis client listening for incoming connections.
I'm not sure what is the real cause of the timeouts... Might it be that I print from python code to console having *.Trace.* properties enabled?
...or is the answer concerning the possibly blocking nature of Redis connection preventing Glacier2 client's code to execute in a timely fashion?
Please, share your thoughts.
PS when Glacier2 client goes down, lots of print 'monitor_queue' and print 'listen' strings ( please see the code below ) flushed to the console log.
UPDATE: Here is the Glacier2 client's log.
I've used Glacier2.Application class in my python client ( on linux ). The problem is that the client reports connection lost from time to time.
Please, have a look at the code. Note the monitor_queue function which, if I'm not mistaken, contains blocking code of a redis client listening for incoming connections.
I'm not sure what is the real cause of the timeouts... Might it be that I print from python code to console having *.Trace.* properties enabled?
...or is the answer concerning the possibly blocking nature of Redis connection preventing Glacier2 client's code to execute in a timely fashion?
Please, share your thoughts.
PS when Glacier2 client goes down, lots of print 'monitor_queue' and print 'listen' strings ( please see the code below ) flushed to the console log.
def runWithSession(self,args): props = self.communicator().getProperties() auth_proxy = self.communicator().getProperties().getProperty('Auth.Proxy') secrt_proxy = self.communicator().getProperties().getProperty('Secrt.Proxy') try: auth_prx = self.communicator().propertyToProxy('Auth.Proxy') secrt_prx = self.communicator().propertyToProxy('Secrt.Proxy') except Ice.ConnectionRefusedException as e: print 'connection refused exception.' if not self.auth_client: print 'auth not found.' sys.exit(1) if not self.secrt_client: print 'secrt not found.' sys.exit(1) self.monitor_queue()
def monitor_queue(self): print 'monitor_queue' p = self.redis_client.pubsub(shard_hint=None) p.psubscribe(self.sub_key) for item in p.listen(): print 'listen()' if ( item['pattern'] == None ): continue if ( item['data'] == 'lpush' ): k = None with self.redis_client.pipeline() as pipe: pipe.rpoplpush('login_queue',self.self_id) pipe.pexpire(self.self_id,self.job_expire_ms) pipe.execute() k = self.redis_client.lrange(self.self_id,0,1)[0] if ( k == None ): continue self.process_session(k)
UPDATE: Here is the Glacier2 client's log.
File "/opt/Ice-3.4.2/python/Glacier2.py", line 181, in doMainInternal status = self.runWithSession(args) File "auth-job.py", line 77, in runWithSession self.monitor_queue() File "auth-job.py", line 97, in monitor_queue self.process_session(k) File "auth-job.py", line 141, in process_session user_id = self.get_user_id(login,password) File "auth-job.py", line 172, in get_user_id obj_usr = self.auth_client.Login(u_email,u_pass) File "/opt/socket.io/ice.compiled/auth_ice.py", line 76, in Login return _M_Auth.IIceAuthenticate._op_Login.invoke(self, ((strName, strPassword), _ctx)) ConnectionLostException: Ice.ConnectionLostException: recv() returned zero 2014-02-05 12:15:22.262990 auth-job.py: error: unexpected exception when destroying the session Traceback (most recent call last): File "/opt/Ice-3.4.2/python/Glacier2.py", line 225, in doMainInternal Application._router.destroySession() File "/opt/Ice-3.4.2/python/Glacier2_Router_ice.py", line 441, in destroySession return _M_Glacier2.Router._op_destroySession.invoke(self, ((), _ctx)) SessionNotExistException: exception ::Glacier2::SessionNotExistException { }
0
Comments
-
OK.
Investigation shows that python client somehow loses its session to Glacier2 server. The client utilizes the Glacier2.Application object.
Does anybody know how to restart a session from within Glacier2.Application?
Please, see the log below:-- 02/06/14 22:18:50.752 /opt/Ice-3.4.2/bin/glacier2router: Glacier2: destroying session id = f7d7a099-5678-4e00-87cd-e39b8571e8db category = *=cs!&cn:zH8}|u<"(IW local address = 192.168.1.4:4063 remote address = 192.168.1.9:49618 -- 02/06/14 22:18:50.754 /opt/Ice-3.4.2/bin/glacier2router: Glacier2: exception while destroying session OutgoingAsync.cpp:643: Ice::ObjectNotExistException: object does not exist: identity: `GameXGrid/702C16F3-B7AF-45A0-93DD-36E5A350A9B4' facet: operation: destroy -- 02/06/14 22:19:39.404 /opt/Ice-3.4.2/bin/glacier2router: Glacier2: rejecting request. no session is associated with the connection. identity: Authenticate
0