[R] JRclient.RSrvException Exception: Handshake

helios16 at gmx.de helios16 at gmx.de
Fri Jun 12 11:39:28 CEST 2009


Hi all,

first of all: Sorry for my bad englis, and now the Question:

I have some problems with running R from Java. First i tried using rJava (JRI). But the examples didnt work properly.

Now im trying to establish a connection by using Rserve and JRclient (RF503). 
I have the following code, which i`ve found:

------------------------------------------------------------------------

public class RTester {


    
    public static void main(String[] args) {
        Rconnection c = getLocalRconnection();
        if (c != null) {
            try {
                double[] d = c.eval("rnorm(10)").asDoubleArray();
                for (double n : d)
                    System.out.println(n);
            } catch (RSrvException e) {
                e.printStackTrace();
            }
        }
    }

    private static Rconnection getLocalRconnection() {
        try {
            return new Rconnection();
        } catch (RSrvException e) {
            //If we get this kind of error, it may be because Rserve is not running
            if (e.getMessage().equals("Cannot connect: Connection refused")) {
                try {
                    String rserveStartCommand = "R CMD Rserve --vanilla";
                    //do a blocking call to the shell command for starting Rserve
                    int exitValue = Runtime.getRuntime().exec(rserveStartCommand).waitFor();
                    //if it returned success, try connecting again
                    if (exitValue == 0)
                        return new Rconnection();
                    //otherwise, Rserve is probably not installed
                    else
                        System.err.println("Could not start Rserve - is it installed properly? Shell command \""+rserveStartCommand+"\" exited with exit value "+exitValue+".");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            else
                e.printStackTrace();
        }
        return null;
    }


-------------------------------------------------------------------------
The Problem ist, that i get the following Exception:
org.rosuda.JRclient.RSrvException: Handshake failed: The server uses more recent protocol than this client.
    at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:113)
    at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:58)
    at org.rosuda.JRclient.Rconnection.<init>(Rconnection.java:42)
    at tester.RTester.getLocalRconnection(RTester.java:28)
    at tester.RTester.main(RTester.java:14)


Well, i understand, that tehre seems to be a version problem, but i dont understand what kind of. Im using the most recent Versions of RServe and JRclient which i could find on the page.

btw. im using Windows XP Pro and Eclipse ganimed (recent Version) as IDE.
Java jdk is at version 1.6.

Thx in advance for any help!

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!




More information about the R-help mailing list