1
votes

I have an Elixir Phoenix node started on one machine and an Erlang node on another. The Erlang node has a process named "rec", that accepts a tuple of three elements: an atom and two charlists. When I run this code on the Elixir node:

Node.spawn_link(node_name, fn -> send(:rec, {:create, uuid, link}) end)

it runs as needed, but when I run it from the Phoenix controller, it returns an error like this:

[error] Error in process #PID<14185.2561.0> on node :"[email protected]" with exit value:
{:undef, [{#Function<0.87309885/0 in SlrRecorderApiWeb.CameraController.add/2>, [], []}]}

What should I do to run it correctly?

1

1 Answers

2
votes

This happens because the module SlrRecorderApiWeb.CameraController is not loaded on the Erlang node in question: when you're sending an fn function to be run on another node, the module where it is defined must be loaded on both nodes.

The good news is that you don't need to use a function here, you can just use:

send({:rec, node_name}, {:create, uuid, link})

and the message will be sent to the process named rec on the other node.