# R Server (RJ)

## General

The RJ server is an R server using Java for process control and communication. It uses Java RMI technology [1] for the client server communication and JRI [2] for the integration of R in Java. One server provides a single R session. You can start multiple servers for the same or for different user on one machine without problems. The different R sessions are registered in the RMI registry and distinguishable by their names.

The RJ server is designed for usage in an intranet, but it also offers the option to use an SSH tunnel for the connections in less secure network environments.

#### Security

Because of the single session approach of the RJ server, one usually starts the server under the user account of the R user. So the R users have the same permissions like in a SSH shell. The login name of the user account defines the "owner" of the R session.

To make sure that no other user obtains the rights of the R session owner, the client server protocol supports login authentication. The default package provides several methods e.g. using PAM of the host system. See the startup script for a list of available methods and their configuration. You may also develop and use your custom methods. It is possible to disable the authentication by setting it to the method `none`. All methods provided by the package uses public key mechanism to encrypt the login data (but no host validation).

The R exchanged data like user input and result output are not encrypted.

## Requirements

Because the server is based on Java, it works theoretically on any platform fulfilling the following requirements):

- Java VM
- R
- R package 'rj'
- R package 'rj.gd' for graphic support

Note that the version of the parts of RJ in StatET, the console server and the R packages must be compatible (same major and minor version, if not published otherwise).

## Setup / Startup

A server bundle containing all files is provided on the homepage. The bundle contains all program files and startup scripts, but not the requirements listed above.

The server requires a running Java RMI registry. The program `rmiregistry` is usually included in the Java distribution. In most case a single RMI registry per computer is sufficient; sometimes it can be handy to use a registry per user. For example you can setup a system job for the registry or insert a start command for the registry in the startup script.

#### Setup

1. Make sure all requirements listed above are installed on the server.
2. Download the consoleserver file from the homepage and extract it into a directory of your choice (default is '~/.RJServer/').
3. Read the instructions in the startup and set the required configuration variables.
4. Start the RMI registry, if not yet done, e.g.: `${JAVA_HOME}/bin/rmiregistry &` .

#### Startup

1. Start a server session as shown in the instructions of the startup file, e.g.: `startup.sh mysession` .
2. In StatET, create a R Remote Console for the server and finally start the R session.

It is also possible to run the first step automatically when starting the session in StatET (second step) by using the launch type "Start over SSH" in the launch configuration of the R Remote Console.

#### Troubleshooting

- Check the log files, they are located in the directory specified by the configuration variable `RJS_WORK` (by default '~/.RJServer/') of the startup script.
- Enabled the debug mode by using the argument `-debug` for the startup script, e.g.: `startup.sh mysession -debug` (does not work in combination with the launch type "Start over SSH").

[1] Java Remote Method Invocation (RMI), http://java.sun.com/javase/technologies/core/basic/rmi
[2] Java/R Interface (JRI), http://www.rforge.net/JRI