Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redix.PubSub doesn't reconnect and die with error :closed #268

Closed
fnicastri opened this issue May 4, 2024 · 8 comments · Fixed by #269
Closed

Redix.PubSub doesn't reconnect and die with error :closed #268

fnicastri opened this issue May 4, 2024 · 8 comments · Fixed by #269
Labels

Comments

@fnicastri
Copy link

We use Redix.PubSub to subscribe a queue on a remote Redis server.
When the connection goes down most of the time Redix.PubSub die with :closed error.
In the same system we use Redix too to send messages to the same server, this process, on the contrary, reconnect without issues.

Using MONITOR we can see the "AUTH" messages on the server.

I can reproduce the error in a clean Phoenix project, you can find it here

Output

iex(1)> {:ok,rec}=Redix.PubSub.start_link([host: "localhost",password: "miTAhlInEWlI", debug: []])
{:ok, #PID<0.714.0>}
# after mocking a network loss
** (EXIT from #PID<0.696.0>) shell process exited with reason: :closed

system

  • Erlang/OTP 26
  • Elixir 1.16.2
  • Redis 6.2.14
  • Redix 1.5.0

also tested with

  • Erlang/OTP 25
  • Elixir 1.15.x
  • Redix 1.2.x
@whatyouhide
Copy link
Owner

On the app that you shared (thanks for that by the way!), I do not see any logs like

** (EXIT from #PID<0.696.0>) shell process exited with reason: :closed

after running the redis-test.sh script.

@fnicastri
Copy link
Author

It's not happening always at the first try, sometimes it works for a few cycles then it die.
Did you try to cycle the network a few times in a row?

image

@whatyouhide
Copy link
Owner

@fnicastri can you try the branch at #269 and see if it fixes it? I think this was actually a bug!

defp deps do
  [
    # ...
    {:redix, github: "whatyouhide/redix", branch: "al/fix-conn-errors-authing"}
  ]
end

@whatyouhide whatyouhide changed the title Redix.PubSub doesn't reconnect and die with error :closed Redix.PubSub doesn't reconnect and die with error :closed May 7, 2024
@fnicastri
Copy link
Author

@whatyouhide

Yes! it works!

Just a quick question: starting the Redix.PubSub directly from the Application Supervisor is the correct way, right?

Thank you

@whatyouhide
Copy link
Owner

starting the Redix.PubSub directly from the Application Supervisor is the correct way, right?

@fnicastri yes it is most likely, it depends on the use case but generally yes.

@fnicastri
Copy link
Author

fnicastri commented May 8, 2024

Thanks @whatyouhide!

I've been running a test for over an hour and it has never missed a reconnection.

@whatyouhide
Copy link
Owner

I released 1.5.1, thanks for reporting and fantastic catch. 💟

@fnicastri
Copy link
Author

Thank you for the amazing work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants