Toniq error

Our application is always failing giving 502 gateway error.
Logs always gives the below error related to toniq. Can someone please guide me how to fix this issue. I am new to elixir and phoenix.

2020-05-06T21:34:02.308613945Z 21:34:02.307 [error] GenServer Toniq.Takeover terminating
2020-05-06T21:34:02.308658845Z ** (stop) exited in: :gen_server.call(nil, {:request, [["", ‘2’, “\r\n”], [["$", ‘8’, “\r\n”, “SMEMBERS”, “\r\n”], ["$", ‘20’, “\r\n”, “toniq:registered_vms”, “\r\n”]]]}, 5000)
2020-05-06T21:34:02.308667345Z ** (EXIT) no process: the process is not alive or there’s no process currently associated with the given name, possibly because its application isn’t started
2020-05-06T21:34:02.308672145Z (stdlib 3.11.2) gen_server.erl:223: :gen_server.call/3
2020-05-06T21:34:02.308676445Z (exredis 0.3.0) lib/exredis.ex:135: Exredis.query/2
2020-05-06T21:34:02.308680745Z (toniq 1.2.3) lib/toniq/takeover.ex:21: Toniq.Takeover.handle_info/2
2020-05-06T21:34:02.308685045Z (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
2020-05-06T21:34:02.308705645Z (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
2020-05-06T21:34:02.308709645Z (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
2020-05-06T21:34:02.308713645Z Last message: :check_takeover
2020-05-06T21:34:02.308747745Z State: %{keepalive_name: Toniq.Keepalive}
2020-05-06T21:34:02.313921444Z 21:34:02.313 [error] GenServer Toniq.Keepalive terminating
2020-05-06T21:34:02.313938144Z ** (stop) exited in: :gen_server.call(nil, {:request, [["
", ‘4’, “\r\n”], [["$", ‘6’, “\r\n”, “PSETEX”, “\r\n”], ["$", ‘48’, “\r\n”, “toniq:41d423a0-8fe1-11ea-af58-0242ac100003:alive”, “\r\n”], ["$", ‘5’, “\r\n”, “10000”, “\r\n”], ["$", ‘54’, “\r\n”, <<131, 116, 0, 0, 0, 2, 100, 0, 15, 108, 97, 115, 116, 95, 117, 112, 100, 97, 116, 101, 100, 95, 97, 116, 110, 8, 0, 48, 177, 171, 192, 242, 141, 12, 22, 100, 0, 10, …>>, “\r\n”]]]}, 5000)
2020-05-06T21:34:02.313972944Z ** (EXIT) no process: the process is not alive or there’s no process currently associated with the given name, possibly because its application isn’t started
2020-05-06T21:34:02.313978644Z (stdlib 3.11.2) gen_server.erl:223: :gen_server.call/3
2020-05-06T21:34:02.313983044Z (exredis 0.3.0) lib/exredis.ex:135: Exredis.query/2
2020-05-06T21:34:02.313987344Z (toniq 1.2.3) lib/toniq/keepalive.ex:41: Toniq.Keepalive.handle_info/2
2020-05-06T21:34:02.313991644Z (stdlib 3.11.2) gen_server.erl:637: :gen_server.try_dispatch/4
2020-05-06T21:34:02.313996144Z (stdlib 3.11.2) gen_server.erl:711: :gen_server.handle_msg/6
2020-05-06T21:34:02.314000444Z (stdlib 3.11.2) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
2020-05-06T21:34:02.314004744Z Last message: :update_alive_key
2020-05-06T21:34:02.314008944Z State: %{identifier: “41d423a0-8fe1-11ea-af58-0242ac100003”}

2020-05-06T21:34:17.799905021Z 21:34:17.797 [info] Application toniq exited: shutdown
2020-05-06T21:34:19.329249210Z {“Kernel pid terminated”,application_controller,"{application_terminated,toniq,shutdown}"}
2020-05-06T21:34:19.330125611Z Kernel pid terminated (application_controller) ({application_terminated,toniq,shutdown})
2020-05-06T21:34:19.330428111Z
2020-05-06T21:34:19.481947139Z Crash dump is being written to: erl_crash.dump…done

Well, is the :toniq app properly started, or its supervision tree put into yours at the correct place? Documentation on https://hexdocs.pm/toniq is rather sparse…

Thanks for prompt response. But I am not sure where to check for your questions. Can you please guide me based on the logs I pasted above which part of the documentation can fix the issue.
Sorry to ask but I am completely new to toniq.

You need to check your application, whether or not you start toniq.

Though there could be a lot of other reasons, why that fails. Might be as well, that something passes nil where a pid or another atom is expected.

We start the redis-server before launching our application.

That was not the question.

The question is, if toniq is configured and started correctly as part of your application.

Also, is it used correctly throughout the application? Are it’s client functions called correctly?

Has the app worked before, or did it start failing without any warning without any changes in a formerly working environment?

The app is working fine, but giving intermittent issues to the user 502 bad gateway error. They are getting 502 gateway error on a screen and we are getting the above error in logs. When they refresh the page the 502 gateway error is no more present. Then again in some another screen they are again getting the same 502 gateway error and same error in logs. So it is becoming very complex as to what is causing this intermittent issue. This toniq error is linked to redis I think as I can something like the below in our code. Do not know how to to fix this intermittent issue.

config :toniq, redis_url: System.fetch_env!(“REDIS_URL”)

So what I mean to say is, a particular functionality of app is working fine once and next time giving error.

Sorry, but without having access to the code, its really hard to tell anything…

So as you say it sometimes works and sometimes not, it seems as if :toniq is started correctly. Therefore I’d check all calls to it. Inserting jobs, or whatever you do with it.

Perhaps also ask the maintainer directly if reachable.

If that does not work out, try to rewrite to use another library for background job processing.