GithubHelp home page GithubHelp logo

Comments (11)

ileitch avatar ileitch commented on August 14, 2024

This should fix the issue. I'm not quite ready to do another release as there are some other changes in master I'd like to test some before I do. If you are able to run rapns from master a try that'd be great.

from rapns.

mobits avatar mobits commented on August 14, 2024

Thank you for the fast response.

I ran rapns from master and, unfortunately, the problem persists. I notice that there is another "stop" situation that could be causing the error.

On deliver_handler_pool.rb

def object_removed_from_pool(object)
  object.stop
end

Could it be causing the error?

from rapns.

ileitch avatar ileitch commented on August 14, 2024

I don't believe so. That stop call is on an instance of DeliveryHandler, which simply sets an instance variable. How did you use rapns from master? I was almost certain that commit would have fixed it.

from rapns.

mobits avatar mobits commented on August 14, 2024

I put

gem 'rapns', :git => 'https://github.com/ileitch/rapns.git', :branch => 'master'

on my Gemfile. Isn't that correct?

from rapns.

mobits avatar mobits commented on August 14, 2024

I tested a little further.

After I restarted, the [ERROR] did stop appearing. Unfortunately, the duplicate error still happens.

Here's the log

[2011-11-28 18:17:51] [Connection 0] Connected to gateway.sandbox.push.apple.com:2195
[2011-11-28 18:17:51] [Connection 1] Connected to gateway.sandbox.push.apple.com:2195
[2011-11-28 18:17:51] [Connection 2] Connected to gateway.sandbox.push.apple.com:2195
[2011-11-28 18:17:51] Ready                            
[2011-11-28 18:18:15] Notification 129 delivered to d46...
[2011-11-28 18:18:16] Notification 131 delivered to c40...
[2011-11-28 18:18:16] Notification 130 delivered to 1a7...
[2011-11-28 18:18:17] Notification 132 delivered to 30a...
[2011-11-28 18:18:17] Notification 133 delivered to 732...
[2011-11-28 18:18:17] Notification 134 delivered to a4a...
[2011-11-28 18:18:17] Notification 133 delivered to 732...
[2011-11-28 18:18:17] Notification 134 delivered to a4a...

Notice that notifications 133 and 134 were sent twice. I thought is had something to do with the 'stop' error but it seems to be something different. Should I open another issue?

from rapns.

ileitch avatar ileitch commented on August 14, 2024

Ah, I see the what the cause of the duplicates is. I'll try get to it in the next few days.

from rapns.

mobits avatar mobits commented on August 14, 2024

Great! I'll keep the master branch. Let me know when you fix the issue so I can test it for you.

from rapns.

blakewatters avatar blakewatters commented on August 14, 2024

Bump on this -- what's the source of the duplicates and how concerned should I be? I have rapns in production and duplicated push notifications are a large concern for me.

from rapns.

ileitch avatar ileitch commented on August 14, 2024

The problem is a race condition. In a nutshell, rapns container a Feeder thread and multiple Delivery threads, they communicate using a thread-safe queue.

The Feeder waits until a Delivery thread is idle and then loads more notifications into the queue. If the Feeder pushes more notifications into the Queue than there are Delivery threads (3 by default), then it is possible for a Delivery thread to become idle and the Feeder load more notifications. The problem is that the Queue may still contain notifications from the previous load, and a notification may enter the queue twice.

The simple fix is to just wait until the Queue is empty before loading more notifications, This is in fact how rapns used to work, but I changed it some while ago to improve throughput.

So the chances of this is somewhat low, but none the less I will look at this later today and see if I can come up with a solution that doesn't hurt throughput.

from rapns.

mobits avatar mobits commented on August 14, 2024

ileitch, now that you explained, everything makes sense.

When I send 1~3 notifications, no problem, but when I send more, the 4th and following notifications are sent twice.

In my case, is very common to send multiple notifications at a time because it is an alert I send to multiple users. It'd be very nice if you find a solution - or at least suggest some workaround I could use until then.

from rapns.

blakewatters avatar blakewatters commented on August 14, 2024

This issue should be closed, I've opened a new duplicate message specific Issue #20

from rapns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.