lib/rpush/daemon/dispatcher/apns_http2.rb in rpush-3.3.1 vs lib/rpush/daemon/dispatcher/apns_http2.rb in rpush-4.0.0
- old
+ new
@@ -13,14 +13,11 @@
def initialize(app, delivery_class, _options = {})
@app = app
@delivery_class = delivery_class
- url = URLS[app.environment.to_sym]
- @client = NetHttp2::Client.new(url,
- ssl_context: prepare_ssl_context,
- connect_timeout: DEFAULT_TIMEOUT)
+ @client = create_http2_client(app)
end
def dispatch(payload)
@delivery_class.new(@app, @client, payload.batch).perform
end
@@ -28,9 +25,19 @@
def cleanup
@client.close
end
private
+
+ def create_http2_client(app)
+ url = URLS[app.environment.to_sym]
+ client = NetHttp2::Client.new(url, ssl_context: prepare_ssl_context, connect_timeout: DEFAULT_TIMEOUT)
+ client.on(:error) do |error|
+ log_error(error)
+ reflect(:error, error)
+ end
+ client
+ end
def prepare_ssl_context
@ssl_context ||= begin
ctx = OpenSSL::SSL::SSLContext.new
begin