[erlang-questions] : First send from JInterface ok, second one blocs??
Alexander Lamb
alexander.lamb@REDACTED
Tue May 13 12:04:52 CEST 2008
I added an OtpNodeStatus to follow the status of the connection and on
the second call here is what I get:
-> LOOKUP (r4) alex@REDACTED
<- PORT 57266
-> MD5 CONNECT TO kirk.local:57266
-> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
-> CLOSE
-- CONNECTION ATTEMPT: alex@REDACTED INCOMING: false INFO:
java.io.IOException: Cannot connect to peer node
Because of the CLOSE, the connection attempt from alex@REDACTED is
refused!
Le 13 mai 08 à 11:33, Alexander Lamb a écrit :
> Le 13 mai 08 à 10:57, Raimo Niskanen a écrit :
>
>> Since you gave no example code I give you counterexample code.
>> I have done a simple RPC call example:
>
> Well, this looks very close to what I am doing I start Erlang like
> that:
>
> erl -mnesia -setcookie rodanotech -sname alex
>
> I start Java (from Eclipse) with those arguments:
>
> -Djetty.home="/Users/alamb/Library/jetty-5.1.14" -
> DOtpConnection.trace=4
>
> When my app starts, I create a node like that:
>
> _otpNode = new OtpNode(OTP_NODE_NAME,OTP_NODE_COOKIE);
>
> with:
>
> public static final String OTP_NODE_COOKIE = "rodanotech";
> public static final String OTP_NODE_NAME = "jnode";
>
> then I have a class wich creates a mailbox in its constructor:
>
> _mbox = _node.createMbox();
>
> Finally, I have a function which sends the message to the server:
>
> private OtpErlangObject callFunctionInModuleOnNodeWithArgs(String
> functionName,String moduleName,String nodeName,OtpErlangList args)
> throws SFExceptionTimeout, SFExceptionError {
> OtpErlangObject[] rpc = new OtpErlangObject[2];
> OtpErlangObject[] call = new OtpErlangObject[5];
>
> call[0] = new OtpErlangAtom("call");
> call[1] = new OtpErlangAtom(moduleName);
> call[2] = new OtpErlangAtom(functionName);
> call[3] = args;
> call[4] = new OtpErlangAtom("user");
> rpc[0] = _mbox.self();
> rpc[1] = new OtpErlangTuple(call);
>
> OtpErlangObject response = null;
>
> _mbox.send("rex", nodeName, new OtpErlangTuple(rpc));
> System.out.println("--- message sent");
> try {
> response = _mbox.receive(_timeout);
> System.out.println("--- message received: " + response);
> } catch(Exception e) {
> System.out.println("*** Error receiving message" + e);
> e.printStackTrace();
> throw new SFExceptionError(e.getMessage());
> }
> if(response == null)
> throw new SFExceptionTimeout();
> try {
> response =
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1); //
> skip "rex"
> OtpErlangAtom status = (OtpErlangAtom)
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(0);
> response =
> ((com.ericsson.otp.erlang.OtpErlangTuple)response).elementAt(1);
> if(status.atomValue().equals("error"))
> throw new SFExceptionError(response.toString());
> } catch(Exception e) {
> System.out.println("*** Error decoding message" + e);
> e.printStackTrace();
> throw new SFExceptionError(e.getMessage());
> }
> return response;
> }
>
>
> Now, the problem is that it works fine the FIRST TIME I call this
> function... but the second time it doesn't and the call doesn't even
> reach my function in Erlang (I added a trace).
> So it can't be a cookie problem since otherwise it would not even
> accept a first connection. Something is doing a "close". Should I do
> somthing special on the Erlang or Java side to make the connection
> persistent?
>
> Here is the trace:
>
> --- TEST START...
> --- INIT OF SESSION...
> --- App module init...
> -> PUBLISH (r4) jnode@REDACTED port=57107
> <- OK
> -> LOOKUP (r4) alex@REDACTED
> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> <- HANDSHAKE recvStatus (ok) local=jnode@REDACTED
> <- HANDSHAKE recvChallenge from=alex@REDACTED challenge=-41504799
> local=jnode@REDACTED
> -> HANDSHAKE sendChallengeReply challenge=-1539340064
> digest=0f7f9711c77b2b1a28c0fab48b502046 local=jnode@REDACTED
> <- HANDSHAKE recvChallengeAck from=alex@REDACTED
> digest=b04515d124bdaa99e579ebaaa88079d4 local=jnode@REDACTED
> -> REG_SEND {6,#Pid<jnode@REDACTED>,'',rex}
> {#Pid<jnode@REDACTED>,{call,profiles,get_default_menus,
> [[84,79,80]],user}}
> --- message sent
> <- 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"}]}}]}}
> --- message received: {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"}]}}]}}
> --- MSG: [{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
> <- PORT 57102
> -> MD5 CONNECT TO kirk.local:57102
> -> HANDSHAKE sendName flags=3332 dist=5 local=jnode@REDACTED
> -> CLOSE
> --- message sent
> --- message received: null
> **** EXCEPTION: ch.rodano.erl_jfoundations.model.SFExceptionTimeout
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list