简体   繁体   中英

Unable to spawn process on another node in Erlang

When I try to create a new process on separate node using

Pid = spawn(mynode, mymodule, myfunction, [self()])

( myfunction/1 is exported), I get this error:

Error in process <0.10.0> on node 'no@de1' with exit value:
{undef,[{mymodule, myfunction, [<33.64.0>], []}]}

I tried to set -compile(export_all) flag, but assuming the additional braces in error log, this is not the case. I don't know what causes the error and I have no clue what to do.

The error you get is saying “There is no module 'mymodule' and/or no function 'mymodule:myfunction/1'”.
This means mymodule is not loaded in the code server of your separate node.
To load mymodule's code there you need something like this snippet or this function

Did you check that the module mymodule is in the path of no@de1?

When you spwan a process using spawn(mynode, mymodule, myfunction, [self()]), the VM needs to load the code before executing it.

If you use a high order function (a fun) in this way spawn(Node, Fun) , then in is not more necessary to have the code in the path (but beware that any call to a function in the function definition need to be solved on the remote node)

go to no@de1 and run m(mymodule). It should clarify if the module is loadable and which functions does export.

also: check if the other node is reachable. Do a net_adm:ping on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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