简体   繁体   English

Phoenix / Erlang节点连接

[英]Phoenix/Erlang node connection

I have an Elixir Phoenix node started on one machine and an Erlang node on another. 我有一台机器上启动了一个Elixir Phoenix节点,而另一台机器上启动了一个Erlang节点。 The Erlang node has a process named "rec", that accepts a tuple of three elements: an atom and two charlists. Erlang节点具有一个名为“ rec”的进程,该进程接受三个元素的元组:一个原子和两个字符列表。 When I run this code on the Elixir node: 当我在Elixir节点上运行此代码时:

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: 它可以根据需要运行,但是当我从Phoenix控制器运行它时,它将返回如下错误:

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

What should I do to run it correctly? 我应该怎么做才能正确运行它?

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. 发生这种情况是因为模块SlrRecorderApiWeb.CameraController没有加载到有问题的Erlang节点上:当您发送要在另一个节点上运行的fn函数时,必须在两个节点上都加载定义了该模块的模块。

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. 消息将被发送到另一个节点上名为rec的进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM