Note that there are some explanatory texts on larger screens.

plurals
  1. POException error: undefined function in Mochiweb/Erlang
    primarykey
    data
    text
    <p>After seeing <a href="http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-2/" rel="nofollow noreferrer">this article</a>, I have been tinkering with mochiweb. While trying to replicate what's done in the article - basically setting up a mochiweb server, having two erlang nodes, and then calling a function defined in one node in the other (after setting net_adm:ping() between the two nodes so they know each other).</p> <p>I was able to follow everything till that function call part. In n1@localhost, which is the mochiweb server, I call (just as done in the article):</p> <pre><code>router:login(IdInt, self()). </code></pre> <p>And then, in n2@localhost, which is the router.erl script, I have defined the login function:</p> <pre><code>login(Id, Pid) when is_pid(Pid) -&gt; gen_server:call(?SERVER, {login, Id, Pid}). handle_call({login, Id, Pid}, _From, State) when is_pid(Pid) -&gt; ets:insert(State#state.pid2id, {Pid, Id}), ets:insert(State#state.id2pid, {Id, Pid}), link(Pid), % tell us if they exit, so we can log them out io:format("~w logged in as ~w\n",[Pid, Id]), {reply, ok, State}; </code></pre> <p>I have pasted only the relevant parts of the code. However, when I now access the webserver on the browser - I get this error report on n1@localhost:</p> <pre><code>=CRASH REPORT==== 11-Jun-2009::12:39:49 === crasher: initial call: mochiweb_socket_server:acceptor_loop/1 pid: &lt;0.62.0&gt; registered_name: [] exception error: undefined function router:login/2 in function mochiconntest_web:loop/2 in call from mochiweb_http:headers/5 ancestors: [mochiconntest_web,mochiconntest_sup,&lt;0.59.0&gt;] messages: [] links: [&lt;0.61.0&gt;,#Port&lt;0.897&gt;] dictionary: [{mochiweb_request_path,"/test/123"}] trap_exit: false status: running heap_size: 1597 stack_size: 24 reductions: 1551 neighbours: =ERROR REPORT==== 11-Jun-2009::12:39:49 === {mochiweb_socket_server,235,{child_error,undef}} </code></pre> <p>After googling around, I got a basic gist of what the error is trying to say - basically it says that the login function being called in n1@localhost is not defined - but it is defined in n2@localhost (and both the nodes know each other - I did <code>nodes().</code> to check) !! Please tell me where I am going wrong!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload