codedge-llc / pigeon

iOS and Android push notifications for Elixir
https://hex.pm/packages/pigeon
MIT License
639 stars 143 forks source link

Cannot start FCM adapter when build for Production #247

Open hNhat195 opened 1 year ago

hNhat195 commented 1 year ago

Environment

Current behavior

I have problem when build my project in production, that here: Kernel pid terminated (application_controller) ({application_start_failure,k_gates,{{shutdown,{failed_to_start_child,'Elixir.KGates.FCM',{shutdown,{failed_to_start_child,1,{{case_clause,{stop,{{{badmatch,{error,{{badmatch,{error,{bad_return_value,{error,etimedout}}}},[{'Elixir.Kadabra.Connection',init,1,[{file,"lib/connection.ex"},{line,44}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,848}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}}},[{'Elixir.Kadabra.ConnectionPool',init,1,[{file,"lib/connection_pool.ex"},{line,59}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,848}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,811}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]},{child,undefined,#Ref<0.2086631506.426246145.164154>,{'Elixir.Kadabra.ConnectionPool',start_link,[#{'__struct__' => 'Elixir.URI',authority => <<"fcm.googleapis.com">>,fragment => nil,host => <<"fcm.googleapis.com">>... When I run on my local machine, it all works well. Can you explain to me what problem I have when I build, that is my setup for FCM in config.exs:

config :k_gates, KGates.FCM,
  adapter: Pigeon.FCM,
  project_id: System.get_env("FCM_APP_NAME", ""),
  service_account_json: File.read!(Path.join(File.cwd!(), "/service-account.json"))

and I added it in application.ex, besides setup

defmodule KGates.FCM do
  use Pigeon.Dispatcher, otp_app: :k_gates
end

Expected behavior

frozencap commented 11 months ago

getting similar issue for APNS

Kernel pid terminated (application_controller) ({application_start_failure,myapp,{{shutdown,
{failed_to_start_child,'Elixir.MyApp.ExternalServices.APNS',{shutdown,{failed_to_start_child,4,{shutdown,
{'Elixir.GenServer',call,[kadabra,{start_child,#{id => #Ref<0.3758452972.159121434.901>,restart => transient,start => 
{'Elixir.Kadabra.ConnectionPool',start_link,[#{'__struct__' => 'Elixir.URI',authority => 
<<"api.push.apple.com">>,fragment => nil,host => <<"api.push.apple.com">>,path => nil,port => 443,query => 
nil,scheme => <<"https">>,userinfo => nil},<0.2980.0>,[{ssl,[{cert.......