Rserve - Binary R server
RForge.net

Rserve

About Rserve
Documentation
Examples
FAQ
News
Download/Files
 
GIT access
Technical Info
Check results
Package R docs

About Rserve
What is Rserve?
        

Rserve is a TCP/IP server which allows other programs to use facilities of R (see www.r-project.org) from various languages without the need to initialize R or link against R library. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++, PHP, JavaScript and Java. Rserve supports remote connection, authentication and file transfer. Typical use is to integrate R backend for computation of statstical models, plots etc. in other applications.

The following Java code illustrates the easy integration of Rserve:

RConnection c = new RConnection();
double d[] = c.eval("rnorm(10)").asDoubles();

d now contains 10 random samples from the N(0,1) distribution if there is a runing Rserve on the local machine. The RConnection doesn't have to be created more than once for subsequent commands (however, each thread must have its own connection object unless synchronized explicitly).

As a side note - if you are looking just for a way to access R from Java in one application without the need for the client/server concept, you may want to have a look at JRI. It uses JNI to link R directly into Java.

The original Rserve paper is available in the DSC-2003 proceedings. Please cite that paper when using Rserve.

NOTE: Rserve is perfect as a back-end for web services and is often used that way. See also FastRWeb.

Tell us about your project!
Some projects using Rserve:
RCloudTableau
The Dataverse Network ProjectPhenyx"J" interface
Nexus BPMTavernaBio7
INTAMAPScreensaver HTS LIMSCRISP
WWARN
If you are using Rserve, please let us know! Please send me an e-mail if your project uses Rserve! Thanks!
What's new?

For a detailed list - see NEWS.

    --- The latest Rserve version available from RForge is Rserve_1.8-14 ---

Previous releases:

2021/11/28Rserve 1.8-11 improvements to Rserve.eval(), security improvements.
2021/11/25Rserve 1.8-10 secLogin security improvements.
2021/11/05Rserve 1.8-9 bugfix release.
2021/10/31Rserve 1.8-8 adds support for SSL client certificates, see tls.client. Minor cleanup and bug-fixes. The default Windows build now supports TLS as well, assuming that OpenSSL is present in the toolchain.
2020/12/17Rserve 1.8-7 mostly proxy updates, fail visibly on errors.
2020/06/11Rserve 1.8-6 added support for large vectors, many improvements in the proxy (IE support, automatic registration with a load-balancer), bugfixes and restored Windows support.
2017/03/25Rserve 1.8-5 adds OCAP idle callback function support.
2015/12/23Rserve 1.8-4 bugfix release (affects proxy and compute-separation mode only).
2015/07/20Rserve 1.8-3 release. Added support for Rserve I/O context and new WebSocket/QAP tunnel proxy with extended static content support (supportes conditional GETs and serving compressed content).
2015/05/20Rserve 1.8-2 bugfix release (only affects WebSocket implementation)
2015/04/08Rserve 1.8-1 released on RForge.net. Added ulog support in R, "fork here" for spawning multiple servers and console input OOB support.
2014/09/03Rserve 1.8-0 released on RForge.net. We are currently restricting the 1.8 series to RForge releases (i.e., CRAN still has 1.7) because some applications may rely on control commands which are currently unsupported in the 1.8 series due to a large overhaul of the communication between the master server and the sessions. All other features are considered stable in the 1.8 series. If you don't require control commands (or don't know what it is) then we strongly recommend installing the latest 1.8 version.
2013/08/21Rserve 1.7-3 released. This relase now restores Windows support (thanks to David Champagne from Revolution Analytics!), it allows HTTPS to WebSockets/TLS upgrade (on unix) and cleans up configuration of the various new possible server configurations.
Features of Rserve
  • fast - no initialization of R is necessary
  • binary transport - the transport protocol sends R objects as binary data, not just R text output.
  • automatic type conversion - most R data types are converted into native data types, e.g. the result of rnorm(10) will be double[10] in C/Java. Java client also provides classes for new R types such as RBool, RList etc.
  • persistent - each connection has its own namespace and working directory. Every object you create is persistent until the connection is closed. The client doesn't have to fetch or store intermediate results.
  • client independence - since the client is not linked to R there are no threading issues like in RSJava etc.
  • security - Rserve provides some basic security by supporting encrypted user/password authentication with server challenge. Rserve can be also configured to accept local connections only. In addition, Rserve support OCAP (object capability) mode which prevents arbitrary code execution and allows the application to expose only individual functions. Finally, Rserve support encrypted connections (TLS/SSL)
  • file transfer - the Rserve protocol allows to transfer files between the client and the server. This way Rserve can be used as a remote server even for task such as generating plot images etc.
  • configurable - one configuration file is used to control settings and to enable/disable features such as authorization, remote access or file transfer.
  • web-server - Rserve can also act as a web-server serving static content and R scripts, and it also supports WebSockets for direct communication from the browser to R enabling highly efficient interactive graphics.
Clients
Rerve comes bundled with Java and a very minimal C++ client, but since it is an open protocol, others have kindly created open-source clients to Rserve as well. If you find another one, please send me an e-mail.
What Rserve is NOT
  • Rserve provides no callback functionality. Your application could implement callbacks via TCP/IP and the R sockets but it is not a part of Rserve.
    (Note: callbacks are now supported using OOB commands in OCAP mode)
  • Rserve is not a telnet frontend to R. The printed output is not transported (except via capture.output). Rserve uses binary protocol for transport of objects for better speed.
    (Note: in OCAP mode console I/O is now supported)
  • Rserve is thread safe across connections, but eval methods are not thread safe within one connection. This means that multiple threads should not use the same connection unless they guarantee that no eval calls are run in parallel.
Older release news
2013/08/12Rserve 1.7-2 released. New keep.alive option and bugfixes
2013/07/02Rserve 1.7-1 is now officially on CRAN. Please see the NEWS for the long list of new features in the new 1.x series. Note that the old Java client has been removed entirely and the REngine-based client now ships in the src/clients/java directory of the source package and the JAR files are even installed in the java directory of the resulting package installation.
Also note that the source repository is now hosted on GitHub - builds and everything else is still performed by RForge.net.
2012/12/10Rserve 1.7-0 is the latest version of Rserve with many new features. Please give it a go - we think it's stable enough. The only reason why it has not been officially released yet is that it currently doesn't support Windows (because many of the new features rely on things lacking in Windows). However, given that it is much more sensible to use unix servers for Rserve deployment (Windows' performance is simply too poor for any server deployment) the majority of users should be able to test the new version and give us feedback.

2012/02/20Rserve 0.6-8 released. Added support for self-control commands as well as RSserverEval(), RSserverSource and control version of RSshutdown.
2012/01/22Rserve 0.6-7 released. This is a security update, if you rely on the built-in authentication, make sure you update at least to this version!
2011/12/10Rserve 0.6-6 released (bugfixes and added support for assigning pure S4 objects)
2011/06/21Rserve 0.6-5 released (Windows-specific updates, use install.libs.R from R 2.13.1 on)
2011/05/19Rserve 0.6-4 released (bugfixes, 64-bit buffer support, changes in Rserve() wrapper)
2011/01/17Rserve 0.6-3 released (added multi-arch support for Windows; update C++ client; one unix bug fix)
2010/09/02Rserve 0.6-2 released (added support for NAs in character vectors; added interactive option - on by default on all platforms; Windows fixes)
2010/05/24Rserve 0.6-1 released (added su and cachepwd config options; added Win64 support; few bugfixes)
2009/10/27Rserve 0.6-0 released (added the concept of control commands aka server-side commands; few bugfixes)
2009/01/25Rserve 0.5-3 released (added string encoding support, allow S3 objects to be synthesized on the client side, added tests, minor fixes)
2008/10/17Rserve 0.5-2 released (fixed bug in readFile and setBufferSize; updated Java client)
2008/07/22Rserve 0.5-1 released (fixes build issues with R 2.7 on Windows and multi-arch install)
2008/07/21Rserve 0.5-0 was released on CRAN. This is a new, major release of Rserve which requires updated client support, because the protocol was substantially changed. It also features a new, efficient R client. Note that the old Java API (JRclient) will no longer be activaley maintained and projects are encouraged to use the new Java API (REngine). This version was in RC stage for quite a long while so hopefully most project switched already. (0.4 versions are still available from RForge for legacy projects, but not from CRAN)
2007/03/15Rserve and its documentation have now officially moved to RForge.
2006/11/15Rserve is now available as a package from CRAN. This also implies that the latest binary versions (both for Windows and Mac OS X) are now available from CRAN. Simply use install.packages("Rserve").
2006/05/03Rserve_0.4-3 released including Windows binary for R 2.3.0. The new 0.4 series supports sessions, i.e. the client can detach from the server and attach to the same session later on (e.g. when the computation has finished). The corresponding new client is now available for download. Also the C++ client has been extended to support authentication and file transfer.
2006/01/31Updated Windows binary for R 2.2.1 based on Rserve 0.4-0
2005/07/27Rserve_0.3-17 released with minor fixes for R 2.1.1 (mainly Windows-related) and corresponding Windows binary.
2005/05/02Updated Windows binary for R 2.1.0.
2005/01/12Rserve_0.3-16 released. It allows custom initialization such that you can pre-load data and libraries, allowing even faster responses for specific tasks.
2004/11/30Rserve_0.3-15 released and corresponding Windows binary for R 2.0.1. Fixes bugs related to empty vectors and features more efficient handling of real vectors on big-endian machines.
2004/10/08Windows binary for R 2.0.0 is provided in the Windows binaries section.
2004/09/27Rserve_0.3-14 released. Now it contains a new C++ client API - it's included in the package in the src/client directory. Further TCP_NODELAY is enabled by default - this can speed up Rserve on low-latency connections.
2004/09/22Rserve_0.3-13 released (fixed R-2.0.0 compatibility issue and file I/O on Sun machines)
2004/08/17Released JRclient-RE817 with additional example (PlotDemo), minor bugfixes and slight accessor modifications.
2004/07/13Rserve Win32 binary for R-1.9.1 provided, see Windows binaries page.
2004/03/21Rserve_0.3-11 and JRclient-RE321 released (bugfix and added support for String[] assignments)
2004/02/02All RoSuDA packages (including Rserve) are now available via install.packages with contriburl="http://www.rosuda.org/R" parameter.
2004/01/02Rserve_0.3-10 released (among others allows the execution of multiple expressions with one 'eval' command).
2003/12/23Rserve_0.3-9 released and the corresponding Windows binary.
2003/10/22Rserve_0.3-6 released, updated JRclient-RDA22.
2003/10/20Rserve_0.3-4 released (fix for moderate data, i.e. 8..16MB; Thanks to Galia Rimon).
2003/10/18Rserve_0.3-3 and updated JRclient released (mostly fixes for large data).
2003/10/15Rserve_0.3-2 released and corresponding Windows binary for R-1.8.0 (minor fixes, see release notes).
2003/10/13Rserve_0.3-1 released. It fixes a serious bug in 0.3-0 which caused Rserve to freeze when returning objects with attributes.
2003/10/08Rserve_0.3-0 and updated Java client released (clients update necessary). Updated FAQ. Updated Windows binary. This version adds support for large data - if you experienced crashes while fetching large data in 0.2 and earlier, use this version instead.
2003/08/21Rserve_0.2-0 and updated Java client released. Please make sure you read the release notes before upgrading, since you must update your clients as well. If you intend to use Rserve on a Sun machine, you should definitely update.
2003/06/24Added Windows binary of Rserve_0.1-9 for R-1.7.1
2003/06/23Rserve_0.1-9 released
  • More flexible configuration (additional command line parameters and config file entries)
  • Added support for local unix sockets
  • Removed fixed buffer size limits
  • Various minor fixes
2003/05/12Added Windows binary for R-1.7.0
2003/05/08Added Frequently Asked Questions section.
2003/04/19Rserve_0.1-8 released (fixes for some platforms)
2003/03/28JRclient-RD328 released.
  • Recommended update, since there was a serious bug in previous versions (objects larger than 50k were truncated).
  • Added assign support.
2003/03/25Rserve_0.1-7 released, Windows binary updated
  • Support for larger data structures (see relase notes)
  • Updated Windows version to accomodate changes in R-1.6.2
  • Make package installable from sources in Windows
2003/03/23Rserve_0.1-5 released
  • Added support for language constructs and closures
  • New commands: CMD_assignSEXP and CMD_setSEXP for creating objects directly
2003/01/29JRclient-RD129 is available for download
2002/12/27Rserve_0.1-4 released
  • Rserve: fixed bug that caused byte-order detection to be ignored. Fixes problems on big-endian systems. Tested successfully with R-1.7.0 devel.
2002/10/01Rserve_0.1-3 released, JRclient updated
  • Rserve: CMD_removeFile added
  • JRclient: new class RFileInputStream uses Rserve's file transfer functionality to transfer files from Rserve (such as images generated by R) to the calling application.

You can read more about the Rserve in the documentation section. Once you read at least the introduction, you can go to the download section to get the necessary files.

Rserve was developed by Simon Urbanek, but anyone interested is welcome to check out the developer section and contribute to the project. The sources are licensed under GPL.