forked from gausby/tortoise
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I am trying to create multiple connections to different mqtt-brokers, but it seems that the client_id is used to register the processes.
Is there a way to achieve this with options I am not aware of, or would it require a change to the library?
Below is my code. When I concat env to the client_id, it does not crash with "already started", but then the server refuses to connect, since the client_id/username/password-combination is incorrect.
pids =
["dev", "stage", "prod"]
|> Enum.map(fn env ->
server_opts = Application.fetch_env!(:my_app, String.to_atom(env))
{:ok, pid} =
Tortoise311.Supervisor.start_child(
MyApp.Connection.Supervisor,
name: {:global, env},
client_id: "my_client_id",
user_name: "my_client_id",
password: "my_client_id",
server: server_opts,
handler: {Tortoise311.Handler.Logger, [env]},
subscriptions: [{"my/topics/#", 0}]
)
IO.inspect(pid)
pid
end)
Metadata
Metadata
Assignees
Labels
No labels