<div dir="ltr"><div>Hello,</div><div><br></div><div>While working with rpc and erpc call and cast I noticed</div><div>a strange behaviour and I don't know if this is intended or not.</div><div><br></div><div>Basically, a call to a Module.function on a local node, :'node1', creates a process sub-tree that stays alive as expected.</div><div><br></div><div>However if the same cal to Module.function is performed from a remote node</div><div>with a rpc or erpc call from ;'node2':</div><div>(node2)> :rpc.cast(:'node1', Elixir.Module, :function, [args]) <br></div><div>the process sub-tree created by Module.function on :'node1' dies .</div><div>I have tried every variant: :rpc.cast/call, :erpc.cast/call, even <br></div><div>:erpc.send_request/wait_response.</div><div><br></div><div>Those calls are made from between nodes running as Elixir nodes.<br></div><div><br></div><div>Nodes are Erlang 24 and Elixir 1.12.2 (:'node2') and Elixir 1.13.0 (:'node1')<br></div><div>The solution I founded is to use a Genserver which apparently keeps the <br></div><div>process sub-tree alive.</div><div><br></div><div>Is it normal that rpc calls cast ro call to end the function on the remote node even if it has the side effects of starting process sub-tree?</div><div><br></div><div>Why is that happening? Is that normal?</div><div><br></div><div>From the manual page:</div><div><a href="https://www.erlang.org/doc/man/rpc.html#call-5">https://www.erlang.org/doc/man/rpc.html#call-5</a></div><div>"... It is used for collecting information on a remote node, or for running a function with some <b>specific side effects </b>on the remote node."</div><div><br></div><div>Those side effects would mean in my case that the process sub-tree to remain alive to use that as a service</div><div>but then again, that side effect disappears once the :rpc.cast/call ends.</div><div><br></div><div>I made a little test:</div><div>I put a :timer.sleep(10_000) at  the end of Module.function<br></div><div>and for 10 seconds the process sub-tree is alive, after that it is killed as</div><div>the function invoked remotely ends.</div><div><br></div><div>I want to invoke that function as a library call, not as a GenServer call.</div><div><br></div><div>How can I do that?</div><div><br></div><div>I want to wrap in GenServer locally the rpc calls to remote node function as a library call.<br></div><div><br></div><div>Cheers,</div><div><br></div><div>Bogdan<br></div><div><br></div><div><br></div></div>