3

This is the code I am working with:

    public class SimpleR {

    public static void main(String args[])
    {
    RConnection re = null;

    try {

    re = new RConnection("192.168.1.151",6311);
    //re = new RConnection("localhost",6311);
            } catch (RserveException e) {
                System.out.println("Connection exception is thrown..."+e.getMessage());
                e.printStackTrace();
            }
            if(re.isConnected())
                System.out.println("Connection established....");
            else
                System.out.println("Can not establish connection");
    }
}

This is the exception I am getting :

Connection exception is thrown...Cannot connect: Connection timed out: connect org.rosuda.REngine.Rserve.RserveException: Cannot connect: Connection timed out: connect at org.rosuda.REngine.Rserve.RConnection.(RConnection.java:88) at org.rosuda.REngine.Rserve.RConnection.(RConnection.java:60) at com.sc.SimpleR.main(SimpleR.java:14) Exception in thread "main" java.lang.NullPointerException at com.sc.SimpleR.main(SimpleR.java:20)

The code is working fine for local Rserve.

I tried this: Running R Code remotely from java application but no luck. Please help.Thanks in advance

Community
  • 1
  • 1
Ajaykumar Kadam
  • 199
  • 1
  • 1
  • 8
  • Is your server working and actually reachable? I'd suggest from a command line `nc -z 192.168.1.151 6311` or on win `telnet 192.168.1.151 6311` to check if it is responding. – Marco Torchiano Feb 25 '15 at 08:26
  • @Mtk the server is reachable it is replying to my PING command but I cannot connect it through telnet please help. THANKS – Ajaykumar Kadam Feb 26 '15 at 05:33
  • if you cannot telnet, it means the Rserve application is not listening on the port. You can (1) check Rserve is up an running, (2) check you have no firewall preventing connections – Marco Torchiano Feb 26 '15 at 11:57
  • this is also my problem. if you could solve this problem, could you give the solution here? – aliakbarian Jun 18 '16 at 05:42
  • the problem was firewall on remote machine... I turned it off and everthing seems ok now – aliakbarian Jun 18 '16 at 10:01

0 Answers0