apnagent icon indicating copy to clipboard operation
apnagent copied to clipboard

Gateway sporadically stops sending notifications

Open bloudermilk opened this issue 10 years ago • 3 comments

It seems there's another bug after fixing #14 and #15 which is causing our agent to stop processing its queue.

Order of events:

  1. 18:23:22 - Last notification sent
  2. Queue begins piling up
  3. 18:24:16 - Cache cleaned out (30s TTL)
  4. 18:26:00 - Invalid token error received
  5. 18:26:03 - Gateway successfully reconnects
  6. Queue continues piling up. No more notifications have been sent since event 1 above.

I don't have any ideas as to why this is happening yet. Let me know if I can provide any more info that might be helpful.

bloudermilk avatar Aug 08 '14 19:08 bloudermilk

It seems like a race condition is putting the queue back into a pause state immediately after it has been resumed. I would start by checking to see if the _queueIterator is even being invoked after .resume()

At a lower level, the queue might decide to not process the next item if any of these conditions pass: https://github.com/qualiancy/breeze-queue/blob/master/lib/queue.js#L200-L203

I'll see what else I can find....

logicalparadox avatar Aug 08 '14 20:08 logicalparadox

Theory: when the last item is sent I don't see a "cache push" notification for id 434787 which would occur here. Coincidentally, that is when next would be called, thus reducing the worker count for the queue. Then, once resume is called it the queue thinks all the workers are still busy so it never invokes the queue iterator for the next item in the queue.

logicalparadox avatar Aug 08 '14 20:08 logicalparadox

Hi, i am seeing similar behaviour, i send lots of events one by one but sometimes it works but sometimes only one or two got delivered and the rest just gone. Is there a simple way to push the queue, like forcing to call process every once in a while with a timeout?

vseryakov avatar Nov 04 '14 18:11 vseryakov