Closed talhaazeemmughal closed 1 month ago
Hi @talhaazeemmughal thanks for the issue.
and where i am trying to use it
I did not understand what this means.
It says redix connection error, reason closed
Can you connect at all? If you try to connect through gen_tcp
, does it work? What's the Redis version?
by this i meant where i am trying to GET the key or SET it. It is giving me this error but it is only on prod.
and where i am trying to use it
@whatyouhide, let me add one more thing that i am using below libraries to implement rate limitting:
{:hammer_backend_redis,` "~> 6.1"},
{:hammer, "~> 6.0"},
{:redix, "~> 0.11", override: true}
also i can connect it using gen_tcp
locally but let me confirm this for the prod.
@whatyouhide i am able to connect prod redis instance using gen_tcp
. i am using redis 7.0.7 on prod
Can you reproduce this in prod with a simple use case? Are you running the same Redis version locally as you are in prod?
for local,redis is dockerised and that one is using 7.2.5
Okay, can you try using the same version? Should be easy if you're using Docker.
@whatyouhide i think it is because of hammer_backend_redis library which requires redix 0.8 and i have 0.11
why i am so sure about that is because i ran Redix.command ping one. i got pong in response and when i did Hammer.check_rate it said the connection closed error.
i upgraded the redix version to 1.1.5 and it is working fine. issue is with hammer library: open an issue there
Nice. Moving the discussion to Hammer then, feel free to reopen if anything points to Redix being the culprit here. 🙃
@whatyouhide i updated redix from 1.1.5 to 1.5.1 and i started to have this error on my prod like environment.
** (ArgumentError) argument error
(kernel 8.3.2) gen_tcp.erl:219: :gen_tcp.connect/4
(redix 1.5.1) lib/redix/connector.ex:33: Redix.Connector.connect_directly/3
(redix 1.5.1) lib/redix/socket_owner.ex:43: Redix.SocketOwner.handle_info/2
(stdlib 3.17.2) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.17.2) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.17.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
any idea what is causing this? i am passing the config like this in config.exs:
config :redix,
url: System.get_env("REDIS_URL", "redis://127.0.0.1:6379"),
pool_size: 30
How are you starting Redix @talhaazeemmughal?
@whatyouhide spawning workers for it using a custom function in
url = Application.get_env(:redix, :url)
pool_size = Application.get_env(:redix, :pool_size)
for i <- 0..(pool_size - 1) do
args = [
url,
[
name: :"redix_#{i}",
socket_opts: redis_socket_opts(url)
]
]
{%{id: {Redix, i}, start: {Redix, :start_link, args}}, :all}
end
adding this list to the children and redis_socket_opts(url)
adds the below is ssl is true
[
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
]
]
What is redis_socket_opts/1
returning?
What is
redis_socket_opts/1
returning? @whatyouhidedefp redis_socket_opts("rediss://" <> _rest) do [ customize_hostname_check: [ match_fun: :public_key.pkix_verify_hostname_match_fun(:https) ] ] end
defp redis_socket_opts(_non_ssl_url), do: []
@talhaazeemmughal can you reproduce this with
Redix.start_link("redis://127.0.0.1:6379", name: :redix_1, socket_opts: [])
?
@talhaazeemmughal can you reproduce this with
Redix.start_link("redis://127.0.0.1:6379", name: :redix_1, socket_opts: [])
?
give me few minutes let me check.
@whatyouhide for testing purposes, i downgraded it to 1.1.5 and then deployed it to the prod like environment. It still failed. So, i think i did some change that is actually causing this.
Ok perfect, I'll leave this issue closed for the time being then. From the error it looks like something wrong with the argument passed to :gen_tcp.connect/4
, so I would check hostname, port, and options. Let me know if you manage to reproduce it and I'll try to raise a better error from Redix if we can.
Ok perfect, I'll leave this issue closed for the time being then. From the error it looks like something wrong with the argument passed to
:gen_tcp.connect/4
, so I would check hostname, port, and options. Let me know if you manage to reproduce it and I'll try to raise a better error from Redix if we can.
@whatyouhide i upgraded exq library as well and this library also uses redix so it could that exq is causing this. i will have a look at it. Thank you for your quick response. i really appreciate it.
I am working on an app that is using
Elixir
version1.10.4-otp-22
andErlang
version is22.3.4.22
.Redix
version is 0.11. i am facing some issues on prod like connection issues and all. if runRedis.command(["PING"]
it returns me pong and where i am trying to use it. It says redix connection error, reason closed. Is it because i am using an outdated version?