Page 1 of 1

[Resolved] Server stops responding after a while ...

PostPosted: 21 Jan 2014, 13:37
by holystone
Hi,

I have written a simple python script to get eye tracking data & it works OK, but only for a small period of time (around 120 frame data replies from server): Now, I thought this had to do with the heartbeat (initially I did not send any heartbeat requests), so I added heartbeat request every few frames but I still get only the same amount of replies of the server (120 frame data replies), after which it does not send any info back to my python script.

As you can see from the script output below, I never get any heartbeat replies back, whatsoever (instead of HEARTBEAT -{"category": "heartbeat" "statuscode": 200} reply I only get a regular frame reply???), which is why my communication between server & the python client stops. Am I missing something here (e.g. using the protocol in a wrong way)?

Thanks in advance!

code snippet (get_frames() is called only once to start receiving tracker data ...):

Code: Select all
   def get_frames(self):
      print "\n======================== GET FRAMES =========================\n"
      #== Get frames ...
      request = '{"category": "tracker","request" : "get","values":["frame"]}'      
      print ">>", request
      self.s.send(request)
      reply = self.s.recv(1024)
      print "<<", reply
      self.print_reply(reply)
      
      #... LOOP ....
      i = 0
      while 1>0:
         #time.sleep(0.01)
         i = i + 1

         #Send Heartbeat request every say 3 frames ...
         if i%3 == 0:
            print "\n Sending HEART BEAT request ... \n\n\n"
            request = '{"category":"heartbeat"}'
            print ".......>> ", request
            reply = self.s.recv(1024)
            print i, ".......<< HEARBEAT reply: ", reply
            print "\n\n"

         reply = self.s.recv(1024)
         print i, ".<<", reply


Here is an output of my logs (>> is what python script sends over socket, << what it receives back):

Trying to connect to Host 127.0.0.1
=== SUCESSFULLY CONNECTED!
=== Starting server in PUSH mode ...
>> {"category": "tracker", "request": "set", "values": {"push": true,"version": 1}}
<< {"category":"tracker","request":"set","statuscode":200}

=== Quering server properties ...:
>> {"category": "tracker","request" : "get","values": [ "heartbeatinterval", "iscalibrated", "iscalibrating", "screenresw", "screenresh"]}
<< {"category":"tracker","request":"get","statuscode":200,"values":{"heartbeatinterval":3000,"iscalibrated":true,"iscalibrating":false,"screenresh":768,"screenresw":1366}}


======================== START GETTING FRAMES! =========================

>> {"category": "tracker","request" : "get","values":["frame"]}
<< {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":649.7051391601563,"y":570.43652343750},"fix":true,"lefteye":{"avg":{"x":635.8280639648438,"y":538.4086303710938},"pcenter":{"x":0.3138372302055359,"y":0.3296629488468170},"psize":25.42731475830078,"raw":{"x":619.8801269531250,"y":539.6589965820313}},"raw":{"x":650.6486816406250,"y":567.371582031250},"righteye":{"avg":{"x":663.5823364257813,"y":602.464355468750},"pcenter":{"x":0.5309650897979736,"y":0.3511711061000824},"psize":26.01738166809082,"raw":{"x":681.4172363281250,"y":595.0841064453125}},"state":7,"time":461126}}}

statuscode: 200 state : 7 timestamp: 461126 fixated: True
coordinates : 649.70513916 : 570.436523438
pupil_sizes : 25.4273147583 : 26.0173816681

1 .<< {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":322.3414611816406,"y":472.7517089843750},"fix":false,"lefteye":{"avg":{"x":130.4935760498047,"y":262.7713928222656},"pcenter":{"x":0.0,"y":0.0},"psize":0.0,"raw":{"x":130.4935760498047,"y":262.7713928222656}},"raw":{"x":322.3414611816406,"y":472.7517089843750},"righteye":{"avg":{"x":514.1893310546875,"y":682.7320556640625},"pcenter":{"x":0.0,"y":0.0},"psize":0.0,"raw":{"x":514.1893310546875,"y":682.7320556640625}},"state":7,"time":516224}}}

statuscode: 200 state : 7 timestamp: 516224 fixated: False
coordinates : 322.341461182 : 472.751708984
pupil_sizes : 0.0 : 0.0


2 .<< {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":450.1688232421875,"y":654.3778686523438},"fix":false,"lefteye":{"avg":{"x":0.0,"y":0.0},"pcenter":{"x":0.0,"y":0.0},"psize":0.0,"raw":{"x":0.0,"y":0.0}},"raw":{"x":450.1688232421875,"y":654.3778686523438},"righteye":{"avg":{"x":450.1688232421875,"y":654.3778686523438},"pcenter":{"x":0.5079099535942078,"y":0.4028982222080231},"psize":26.71464538574219,"raw":{"x":450.1688232421875,"y":654.3778686523438}},"state":4,"time":516300}}}

statuscode: 200 state : 4 timestamp: 516300 fixated: False
coordinates : 450.168823242 : 654.377868652
pupil_sizes : 0.0 : 26.7146453857

...Sending HEART BEAT request ...
>> {"category":"heartbeat"}
<< HEARBEAT reply: {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":224.7973175048828,"y":326.7716064453125},"fix":false,"lefteye":{"avg":{"x":0.0,"y":0.0},"pcenter":{"x":0.0,"y":0.0},"psize":0.0,"raw":{"x":0.0,"y":0.0}},"raw":{"x":0.0,"y":0.0},"righteye":{"avg":{"x":224.7973175048828,"y":326.7716064453125},"pcenter":{"x":0.508530318737030,"y":0.3948508501052856},"psize":25.91179847717285,"raw":{"x":0.0,"y":0.0}},"state":4,"time":516313}}}


3 .<< {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":313.4484558105469,"y":437.0718078613281},"fix":false,"lefteye":{"avg":{"x":0.0,"y":0.0},"pcenter":{"x":0.0,"y":0.0},"psize":0.0,"raw":{"x":0.0,"y":0.0}},"raw":{"x":490.7659606933594,"y":657.9301147460938},"righteye":{"avg":{"x":313.4484558105469,"y":437.0718078613281},"pcenter":{"x":0.5076760649681091,"y":0.3983683586120606},"psize":25.60788345336914,"raw":{"x":490.7659606933594,"y":657.9301147460938}},"state":4,"time":516346}}}

statuscode: 200 state : 4 timestamp: 516346 fixated: False
coordinates : 313.448455811 : 437.071807861
pupil_sizes : 0.0 : 25.6078834534

........ ...........


122 .<< {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":494.4030151367188,"y":655.4321899414063},"fix":true,"lefteye":{"avg":{"x":526.6885375976563,"y":663.0609130859375},"pcenter":{"x":0.2695274055004120,"y":0.4472879767417908},"psize":23.88414382934570,"raw":{"x":526.6885375976563,"y":663.0609130859375}},"raw":{"x":525.2179565429688,"y":678.7269287109375},"righteye":{"avg":{"x":529.6823120117188,"y":676.6044311523438},"pcenter":{"x":0.4813105762004852,"y":0.4377747178077698},"psize":24.16241073608398,"raw":{"x":523.7473754882813,"y":694.3928833007813}},"state":7,"time":522041}}}

statuscode: 200
state : 7 timestamp: 522041 fixated: True
coordinates : 494.403015137 : 655.432189941
pupil_sizes : 23.8841438293 : 24.1624107361

...Sending HEART BEAT request ...
>> {"category":"heartbeat"}
<< HEARTBEAT reply: {"category":"tracker","request":"get","statuscode":200,"values":{"frame":{"avg":{"x":497.5699157714844,"y":656.6991577148438},"fix":true,"lefteye":{"avg":{"x":518.9464721679688,"y":642.2291870117188},"pcenter":{"x":0.2684638202190399,"y":0.4479719698429108},"psize":23.63873291015625,"raw":{"x":518.9464721679688,"y":642.2291870117188}},"raw":{"x":538.4395141601563,"y":666.1760253906250},"righteye":{"avg":{"x":530.5222167968750,"y":677.6840209960938},"pcenter":{"x":0.4816762804985046,"y":0.4389816522598267},"psize":24.13949394226074,"raw":{"x":557.9325561523438,"y":690.1229248046875}},"state":7,"time":522080}}}


123 .<<
====== NO REPLY !!!

Re: Server stops responding after a while ...

PostPosted: 21 Jan 2014, 17:15
by holystone
Oops, I am sorry, my mistake, it seems i forgot to actually send the heartbeat request :)
Now it is working great !

Re: Server stops responding after a while ...

PostPosted: 28 Jan 2014, 03:35
by Martin
Good to hear :)