s-u / REngine

General Java interface to R supporting multiple back-ends such as JRI and Rserve
Other
67 stars 47 forks source link

RServe on windows does NOT allow multiple logins for the same user #16

Closed hlms closed 7 years ago

hlms commented 7 years ago

When R is installed on a linux system, RServe does allow multiple logins for the same user.

Sample code:

import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;

public class TestMultipleLogin {

    public static void main(String[] args) throws RserveException {

        String username = "linuxUser";
        String password = "linuxUser";
        String url = "linuxHost";
        int port = 6311;

        RConnection rconnection;
        for (int i = 0; i < 3; i++) {
            System.out.println((i + 1) + " ... connecting.");
            rconnection = new RConnection(url, port);
            System.out.println((i + 1) + " ... created RConn object.");
            rconnection.login(username, password);
            System.out.println((i + 1) + " ... logged in.");
        }
    }
}

It works, output is follows:

1 ... connecting.
1 ... created RConn object.
1 ... logged in.
2 ... connecting.
2 ... created RConn object.
2 ... logged in.
3 ... connecting.
3 ... created RConn object.
3 ... logged in.

When R is installed on windows, the call new RConnection(url, port) gets blocked while attempting second login. Here is the ouput:

1 ... connecting.
1 ... created RConn object.
1 ... logged in.
2 ... connecting.

Seems to be an issue with RServe. Any solutions or alternatives?

s-u commented 7 years ago

No this is an issue with Windows. From the documentation:

All platforms except Windows support parallel connections and local (unix) sockets.

Windows doesn't support proper fork() so it is unable to handle parallel connections.

hlms commented 7 years ago

Thanks @s-u . Would you provide me the link to the documentation?

Edit:

Thanks for the quick response. I have got the documentation link: https://rforge.net/Rserve/faq.html#platform.