I set up the redis adapter according to the doc and deployed it to Heroku where we have 2 dynos running like(I think all dynos start with the same cmd):
elixir --sname server -S mix phx.server
I didn’t set the node_name
manually to let it pick the one of --sname
:
{Phoenix.PubSub,
adapter: Phoenix.PubSub.Redis,
url: System.get_env("REDIS_URL"),
name: WebInterface.PubSub},
But it didn’t work: messages still not sync between nodes. So am i missing something? Must the node_name
be unique for all the dynos/nodes?
Sadly this is not possible unless you use Private Spaces. Dynos are strictly firewalled off from each other
I know we can’t use build-in distributed elixir for pubsub, so according to the doc, we can use redis instead. So it is supposed to work.
Quite right. My mistake.
My suspicion would be that the sname is not unique for each node (e.g. 127.0.0.1 is often chosen as the host in these scenarios), as you hint at - if you query it for the process on a random dyno, what does it return?
Sorry, my fault. The there was some problem about the redis connection with ssl. After fixing it, it worked.
1 Like