[erlang-questions] otp.net

6 views
Skip to first unread message

Serge Aleynikov

unread,
Oct 2, 2008, 10:32:37 PM10/2/08
to Erlang Users' List
While playing with the otp.net project for the past several days I ran
into one problem that I can't quite explain. I am starting a .NET node
(saleyn@dev_serge2) and connecting to a regular Erlang node
(a@dev_serge2), then send a Pid from .NET to Erlang and try to set up a
monitor. The monitor call fails with badarg:

(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

Serge Aleynikov

unread,
Oct 4, 2008, 1:32:55 AM10/4/08
to Erlang Users' List
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.

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);

Vlad Dumitrescu

unread,
Oct 4, 2008, 7:07:12 AM10/4/08
to Serge Aleynikov, Erlang Users' List
Hi Serge,

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

Serge Aleynikov

unread,
Oct 4, 2008, 9:17:35 AM10/4/08
to Vlad Dumitrescu, Erlang Users' List
Vlad Dumitrescu wrote:
> 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.

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

Reply all
Reply to author
Forward
0 new messages