[erlang-questions] : First send from JInterface ok, second one blocs??

Raimo Niskanen raimo+erlang-questions@REDACTED
Tue May 13 10:57:21 CEST 2008


Since you gave no example code I give you counterexample code.
I have done a simple RPC call example:
======================================
import com.ericsson.otp.erlang.*;

public class jrpc {
    public static void main(String[] argv) {
	System.out.println("jrpc hello world!");
	
	try {
	    OtpNode node = new OtpNode(argv[0], argv[1]);
	    OtpMbox mbox = node.createMbox();
	    
	    OtpErlangObject[] call = new OtpErlangObject[5];
	    call[0] = new OtpErlangAtom("call");
	    call[1] = new OtpErlangAtom("erlang");
	    call[2] = new OtpErlangAtom("display");
	    call[3] = new OtpErlangList(new OtpErlangAtom(argv[3]));
	    call[4] = new OtpErlangAtom("user");
	    
	    OtpErlangObject[] req = new OtpErlangObject[2];
	    req[0] = mbox.self();
	    req[1] = new OtpErlangTuple(call);
	    
	    OtpErlangTuple request = new OtpErlangTuple(req);
	    System.out.println("Sending: "+request);
	    mbox.send("rex", argv[2], request);
	    OtpErlangObject reply = mbox.receive();
	    System.out.println("Received: "+reply);
	    
	    System.out.println("Sending: "+request);
	    mbox.send("rex", argv[2], request);
	    reply = mbox.receive();
	    System.out.println("Received: "+reply);
	} catch (java.io.IOException e) {
	    System.out.println("Exited: "+e);
	} catch (OtpErlangException e) {
	    System.out.println("Exited: "+e);
	}
    }
}
======================================



I compile it and then start an erlang node "e@REDACTED". Then:

$java -DOtpConnection.trace=4 jrpc j@REDACTED `cat ~/.erlang.cookie` e@REDACTED hello
jrpc hello world!
-> PUBLISH (r4) j@REDACTED port=10793
<- OK
Sending: {#Pid<j@REDACTED>,{call,erlang,display,[hello],user}}
-> LOOKUP (r4) e@REDACTED
<- PORT 29584
-> MD5 CONNECT TO localhost:29584
-> HANDSHAKE sendName flags=3332 dist=5 local=j@REDACTED
<- HANDSHAKE recvStatus (ok) local=j@REDACTED
<- HANDSHAKE recvChallenge from=e@REDACTED challenge=-250041024 local=j@REDACTED
-> HANDSHAKE sendChallengeReply challenge=2117997141 digest=82c7630368bc22523d0333142822ac34 local=j@REDACTED
<- HANDSHAKE recvChallengeAck from=e@REDACTED digest=b4d2aef7cb4a2e116842ff944e0a874e local=j@REDACTED
-> REG_SEND {6,#Pid<j@REDACTED>,'',rex}
   {#Pid<j@REDACTED>,{call,erlang,display,[hello],user}}
<- SEND {2,'',#Pid<j@REDACTED>}
   {rex,true}
Received: {rex,true}
Sending: {#Pid<j@REDACTED>,{call,erlang,display,[hello],user}}
-> REG_SEND {6,#Pid<j@REDACTED>,'',rex}
   {#Pid<j@REDACTED>,{call,erlang,display,[hello],user}}
<- SEND {2,'',#Pid<j@REDACTED>}
   {rex,true}
Received: {rex,true}

On e@REDACTED it prints `hello' twice in the console. All is well.
If I on the other hand use the wrong connection cookie:

$ java -DOtpConnection.trace=4 jrpc j@REDACTED `cat ~/.erlang.cookie`XXX e@REDACTED hello
jrpc hello world!
-> PUBLISH (r4) j@REDACTED port=1075
<- OK
Sending: {#Pid<j@REDACTED>,{call,erlang,display,[hello],user}}
-> LOOKUP (r4) e@REDACTED
<- PORT 29584
-> MD5 CONNECT TO localhost:29584
-> HANDSHAKE sendName flags=3332 dist=5 local=j@REDACTED
<- HANDSHAKE recvStatus (ok) local=j@REDACTED
<- HANDSHAKE recvChallenge from=e@REDACTED challenge=-1931661201 local=j@REDACTED
-> HANDSHAKE sendChallengeReply challenge=-430223828 digest=02405e8c4263de8ac92f09ec82804b07 local=j@REDACTED
-> CLOSE



The j@REDACTED apparently hangs in the mbox.send(), and
e@REDACTED prints:

=ERROR REPORT==== 13-May-2008::10:43:05 ===
** Connection attempt from disallowed node j@REDACTED ** 



On Mon, May 12, 2008 at 07:32:22PM +0200, Alexander Lamb wrote:
> Some more information: even if I create a new mailbox before each  
> send, it behaves the same way. Impossible to do a second message send  
> (or a ping). If I restart the java application, even without  
> restarting the erlang server, it again works for the first send.
> 
> Alex
> 
> Le 12 mai 08 à 18:43, Alexander Lamb a écrit :
> 
> > Hello,
> >
> > I have something curious happening when sending messages to the rex
> > rpc server.
> >
> > The first time I send a message, everything is ok. The second time, it
> > blocs and I finally get a timeout (e.g. the response is null).
> >
> > I activated the trace, and here is what I get:
> >
> > -> PUBLISH (r4) jnode@REDACTED port=55076
> > <- OK
> > -> LOOKUP (r4) alex@REDACTED
> > <- PORT 55021
> > -> MD5 CONNECT TO kirk.local:55021
> > -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> > <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> > <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=1257096912
> > local=jnode@REDACTED
> > -> HANDSHAKE sendChallengeReply challenge=-63103116
> > digest=16202c1233ac821560450cd85550f542 local=jnode@REDACTED
> > <- HANDSHAKE recvChallengeAck from=alex@REDACTED
> > digest=c223cd415468ff024d0529992ab8ec48 local=jnode@REDACTED

Since you got the "<- HANDSHAKE recvChallengeAck" it 
is not the connection cookie.

> > -> REG_SEND {6,#Pid<jnode@REDACTED>,'',rex}
> >    {#Pid<jnode@REDACTED>,{call,profiles,get_default_menus,
> > [[84,79,80]],user}}
> > <- SEND {2,'',#Pid<jnode@REDACTED>}
> >    {rex,{ok,[{menu,home,{{home,"Home"},[{login,"Login"},
> > {logout,"Logout"},{about,"About"}]}},{menu,patients,
> > {{patients,"Patients"},[]}},{menu,centers,{{centers,"Centers"},
> > [{search,"Search"},{list,"List"}]}},{menu,dashboard,
> > {{dashboard,"Dashboard"},[{enrollment,"Enrollment"},
> > {statistics,"Statistics"},{initiation,"Initiation"}]}}]}}
> > -> LOOKUP (r4) alex@REDACTED

Are you initiating another connection to an already
connected node?

> > <- PORT 55021
> > -> MD5 CONNECT TO kirk.local:55021
> > -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED

You got thrown out this early. The other node does
not like you. I think it is duplicate connections.
See my example above of sending twice.

> > -> CLOSE
> >
> >
> > So the funny thing is that something is doing a CLOSE. What does that
> > mean??
> >
> > Thanks,
> >
> > Alex
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list