alloy / lowdown

A Ruby client for the HTTP/2 version of the Apple Push Notification Service.
MIT License
120 stars 15 forks source link

Creating a persistent connection freezes the process #30

Closed ky1ejs closed 7 years ago

ky1ejs commented 7 years ago

Hey @alloy, thanks for the great project.

To give some context, I'm quite a ruby n00b, so apologies if anything in this issue seems a bit naive or ill-educated.

Whenever I create a persistent connection, my process freezes. I've reproduced this in irb by simply creating a persistent connection. However, I can press CTL + C to continue using irb and send notifications over the connection.

My initialisation in irb was:

client = Lowdown::Client.production(false,
                                              certificate: File.read(/path/to/pem),
                                              keep_alive: true)

My initialisation in my worker was:

  def dev_pool
    dev_pool = nil
    dev_mutex.synchronize do
      require 'lowdown' # <-- just-in-time loading of Lowdown
      @dev_pool ||= Lowdown::Client.production(false,
                                              certificate: File.read(ENV['APNS_DEV_PEM']),
                                              pool_size: 3,
                                              keep_alive: true)
      dev_pool = @dev_pool
    end
    dev_pool
  end

  def prod_pool
    prod_pool = nil
    prod_mutex.synchronize do
      require 'lowdown' # <-- just-in-time loading of Lowdown
      @prod_pool ||= Lowdown::Client.production(true,
                                                certificate: File.read(ENV['APNS_PROD_PEM']),
                                                pool_size: 3,
                                                keep_alive: true)
      prod_pool = @prod_pool
    end
    prod_pool
  end

The above is taken from previous issues I've seen in this repo.

alloy commented 7 years ago

Hey @kylejm, I wouldn’t know from the top of my head why that would happen. However, I should note that I’ve recently been considering deprecating this gem in favour of @ostinelli’s apnotic, who seems to have more time to maintain his lib than I do. So maybe you should give that a try first? If you do, let me know how it went.

ky1ejs commented 7 years ago

Hey @alloy, thanks for the quick response 😊.

I actually tried agnotic out immediately after creating this issue - it works brilliantly. There are parts of the API (mainly naming) that I prefer about lowdown, but as you say, this is a well maintained lib.

Thank you so much for taking the time to share lowdown with us all!

alloy commented 7 years ago

Thanks for letting me know and the kind words! 🙏