ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
479 stars 94 forks source link

How to heal connection after errors when using Sidekiq #102

Open favrik opened 3 years ago

favrik commented 3 years ago

Hello!

I'm using the worker example as a basis of my implementation, and all is fine until I get an exception in the worker, this goes through the Sidekiq retry flow, but on subsequent retries it appears the connection has not healed, is this expected? And if so, do you have any pointers on how to heal the connection?

It's super weird, after going through a lot of the issues, and finding other implementations (https://github.com/search?q=Apnotic&type=code and https://github.com/feedbin/feedbin/blob/a4d1423fceb5418782fb086e8a6211d73d20ad46/app/jobs/device_push_notification_send.rb) it looks like the worker as provided in the example should be enough.

Thanks!

benubois commented 3 years ago

I haven't been able to test this since for some reason I never get broken connections.

I think the reload method from connection_pool is supposed to do exactly this:

You can reload a ConnectionPool instance in the case it is desired to close all connections to the pool and, unlike shutdown, afterwards recreate connections so the pool may continue to be used.

pool = Apnotic::ConnectionPool.new…
pool.reload { |connection| connection.close }

Ideally this should be addressed in net-http2 since connection_pool expects:

There is no provision for repairing or checking the health of a connection; connections should be self-repairing. This is true of the Dalli and Redis clients.