(a@dev_serge2)2> register(test, self()).
true
(a@dev_serge2)3> nodes(hidden).
[saleyn@dev_serge2]
(a@dev_serge2)4> f(M), M = receive M -> M end.
<5852.1.0>
(a@dev_serge2)5> M ! {hello, self()}.
{hello,<0.50.0>}
(a@dev_serge2)6> erlang:monitor(process, M).
** exception error: bad argument
in function erlang:monitor/2
called as erlang:monitor(process,<5852.1.0>)
(a@dev_serge2)7>
I am able to send messages back and forth between two nodes and verify
their delivery, but don't understand why the monitor call would fail.
Does anyone have a clue?
Serge
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Can anyone explain what's wrong?
(server@dev_serge2)10> {test, client@dev_serge2} ! {self(), hello}.
{<0.45.0>,hello}
(server@dev_serge2)11> f(), {Pid, _} = receive M -> M end.
{<5979.1.0>,hello}
(server@dev_serge2)12> erlang:monitor(process, Pid).
** exception error: bad argument
in function erlang:monitor/2
called as erlang:monitor(process,<5979.1.0>)
The corresponding java node was implemented using code below:
import com.ericsson.otp.erlang.*;
public class test {
public static void main (String args[]) {
System.out.println ("Hello World!");
try {
OtpSelf self = new OtpSelf("client", "abc123");
OtpPeer other = new OtpPeer("server");
OtpConnection connection = self.connect(other);
connection.sendRPC("erlang","date",new OtpErlangList());
OtpErlangObject received = connection.receiveRPC();
System.out.println("erlang:date() -> " + received + "\n");
OtpErlangObject o;
OtpErlangTuple msg;
OtpErlangPid from;
while (true) {
try {
o = connection.receive();
if (o instanceof OtpErlangTuple) {
msg = (OtpErlangTuple)o;
from = (OtpErlangPid)(msg.elementAt(0));
connection.send(from, new OtpErlangTuple(
new OtpErlangObject[] {
self.pid(),
msg.elementAt(1)
}
) );
}
}
catch (Exception e) {
System.out.println("" + e);
}
}
} catch (Exception e) {
System.out.println("" + e);
On Sat, Oct 4, 2008 at 07:32, Serge Aleynikov <sal...@gmail.com> wrote:
> I tried a similar test using jinterface to see if it's possible to
> monitor processes running on a Java node and ran into the same failure.
> (server@dev_serge2)12> erlang:monitor(process, Pid).
> ** exception error: bad argument
> in function erlang:monitor/2
> called as erlang:monitor(process,<5979.1.0>)
The documentation for erlang:monitor/2 says:
"If an attempt is made to monitor a process on an older node (where
remote process monitoring is not implemented or one where remote
process monitoring by registered name is not implemented), the call
fails with badarg. "
The Java nodes aren't implementing everything that an Erlang node
does, and I process monitoring is one of the things that is missing.
In Java it is quite dificult (IMO) to have an Erlang-like setup with
many mailboxes in separate threads. It gets hairy pretty fast. I am
using only two mailboxes and then it is good enough to do the
monitoring with erlang:monitor_node/1.
I was considering to implement this kind of features for Java nodes,
but never got enough time and motivation (you know, if it doesn't
itch, one doesn't have to scratch it :-)
regards,
Vlad
I guess I had higher hopes for jinterface (and consequently otp.net). :-(
> In Java it is quite dificult (IMO) to have an Erlang-like setup with
> many mailboxes in separate threads. It gets hairy pretty fast. I am
> using only two mailboxes and then it is good enough to do the
> monitoring with erlang:monitor_node/1.
Actually, my overall goal was to establish the reverse - monitor an
Erlang process from a .NET client (or java), where the client implements
a UI application that establishes subscription with a process for
receiving events of some sort, and tries to reestablish subscription if
it detects that the remote process died.
Serge