Skip to content

Commit ba93e9a

Browse files
committed
fix: incorrect epmd node formatting
this was preventing NodePortMapper from properly registering nodes, causing disconnections and crashes when more than one engine node was spawned.
1 parent 60fad44 commit ba93e9a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/forge/lib/forge/epmd.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ defmodule Forge.EPMD do
8282
end
8383

8484
def port_please(~c"expert-project-" ++ _ = name, host, timeout) do
85-
if port = Forge.NodePortMapper.get_port(List.to_atom(name)) do
85+
host_string = format_host(host)
86+
full_node = :"#{name}@#{host_string}"
87+
88+
if port = Forge.NodePortMapper.get_port(full_node) do
8689
{:port, port, @epmd_dist_version}
8790
else
8891
:erl_epmd.port_please(name, host, timeout)
@@ -93,6 +96,9 @@ defmodule Forge.EPMD do
9396
:erl_epmd.port_please(name, host, timeout)
9497
end
9598

99+
defp format_host({a, b, c, d}), do: "#{a}.#{b}.#{c}.#{d}"
100+
defp format_host(host) when is_list(host), do: List.to_string(host)
101+
96102
defdelegate start_link, to: :erl_epmd
97103
defdelegate listen_port_please(name, host), to: :erl_epmd
98104
defdelegate address_please(name, host, family), to: :erl_epmd

0 commit comments

Comments
 (0)