Giter Site home page Giter Site logo

s-u / rserve Goto Github PK

View Code? Open in Web Editor NEW
273.0 33.0 63.0 2.19 MB

Fast, flexible and powerful server providing access to R from many languages and systems

Home Page: http://RForge.net/Rserve

License: Other

R 1.04% Shell 0.62% C 82.87% C++ 8.52% PHP 1.89% HTML 0.71% Makefile 0.19% M4 4.15%

rserve's Introduction

Rserve

Fast, flexible and powerful server providing access to R from many languages and systems

CRAN RForge GitHub

To install the CRAN version, use simply

install.packages("Rserve")

For installation of the latest development version, use

install.packages("Rserve", repo="https://rforge.net")

Please see the main Rserve website for documentation, examples and details. Additional information is also available on the Rserve Wiki.

Rserve supports native QAP1 protocol, HTTP and WebSockets. All protocols are also available over TLS/SSL. A reverse proxy is also included for mapping HTTP/WebSockets traffic to local unix sockets for security (unix only).

For building REST APIs based on Rserve see RestRserve, for web-scripting see FastRWeb, for interactive applications see RCloud and Rserve-js.

Note: Although it is possible to use Rserve on Windows, it is strongly discouraged (other than for toy/single-user applications), because the Windows operating system is severly limited and is not capable of using R in parallel (it lacks copy-on-write fork).

rserve's People

Contributors

daef avatar ereztourjeman avatar gordonwoodhull avatar kalibera avatar khoran avatar s-u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rserve's Issues

Rserve for real-time performance tips

I am developing a REST service that uses a Machine Learning model of R. This service will be used by a web page of well-known company, so the traffic will be a high and it must be a 24/7 service. My idea is to use the RServe to calculate the predictions based of the model using R. Although I have played some time with RServe sharing the connection among consecutive requests, I have some doubts:

  • Could the performance degenerate over the time?
  • Is a good practice to share the session among consecutive requests?
  • Is a good approach to use Rserve for this real-time service?

respond with 101 Switching Protocols on websocket upgrade

Just for kicks, I'm checking whether Microsoft Edge (currently the most standards-compliant browser haha) works with RCloud.

The first problem I'm running into is that the response to the websocket upgrade seems to be incorrect. Apparently Rserve still tries to serve the requested path and responds with the corresponding http response.

Typically people will request an url like ws://domain.com:8080/websocket

According to this random bug report (too lazy to read the spec myself, sorry),

RFC-6455 ... specifies that the server should response with
HTTP/1.1 101 Switching Protocols
(http://tools.ietf.org/html/rfc6455#section-1.3)

Instead Rserve responds with 200 if the path specifies an existing file, and 404 otherwise. Edge's WebSocket implementation then barfs with

WebSocket Error: Incorrect HTTP response. Status code 200, OK

I'm not sure if it's worthwhile to address this since probably something else won't work, but I thought I'd report this in case it's easy to fix.

Searching for the error message above will turn up various discussions claiming that Microsoft is right about this one (if pedantic) and Firefox and Chrome's implementations are too lenient.

Large data.frame is corrupted when row.names is includes in 1.7-3, but not 0.6-8

I have a large data.frame (The encoded message is around 33MB) that is encoded by my client, send to the server (both on Windows 7, using R 2.15.3), received by the server and processed correctly by server in v. 0.6-8, but the data is corrupted under v 1.7-3. When I send the SEXP to the server, the server responds saying that everything is OK. The corruption appears when validating the SEXP at the server (and thus when retrieving the same SEXP from the server).

Using 0.6-8, when I call str() and then str(rownames()) on the data.frame then I see the following in the server:

Rserve: Ok, ready to answer queries.
'data.frame':   1500003 obs. of  3 variables:
 $ Date    : Date, format: "2014-02-10" "2014-02-09" ...
 $ Integers: int  0 1 2 3 4 5 6 7 8 9 ...
 $ Doubles : num  -31.123 0.954 0.592 0.389 0.467 ...
 chr [1:1500003] "2" "3" "4" "5" "6" "7" "8" "9" "10" ...

However, using 1.7-3, when I call str() I see the follow:

Rserve: Ok, ready to answer queries.
List of 3
 $ : Date[1:1500003], format: "2014-02-10" "2014-02-09" ...
 $ : int [1:1500003] 0 1 2 3 4 5 6 7 8 9 ...
 $ : num [1:1500003] -31.123 0.51 0.237 0.71 0.882 ...
 - attr(*, "assigns2")=Error: cannot allocate vector of size 5.7 Mb
In addition: Warning messages:
1: In do.call(str, c(list(object = obj), aList, list(...)), quote = TRUE) :
  Reached total allocation of 2047Mb: see help(memory.size)
2: In do.call(str, c(list(object = obj), aList, list(...)), quote = TRUE) :
  Reached total allocation of 2047Mb: see help(memory.size)
3: In do.call(str, c(list(object = obj), aList, list(...)), quote = TRUE) :
  Reached total allocation of 2047Mb: see help(memory.size)
4: In do.call(str, c(list(object = obj), aList, list(...)), quote = TRUE) :
  Reached total allocation of 2047Mb: see help(memory.size)

And calling str(rownames()) using using 1.7-3 just shows NULL at the server.

It's interesting that the exact same data.frame, without any rownames (so just using the default rownames for a data.frame), causes no corruption. So perhaps there's a bug related to attributes in 1.7-3? After sending the data.frame without rownames and then sending the data.frame with row.names, Rserve is at just under 200MB. But when I call str(), Rserve shoots up to over 2GB. There is not anywhere close to 2GB of data in R.

Note that in both cases (0.6-8 and 1.7-3) that I am using the exact same installation of R. The only difference between the two tests is literally the Rserve folder under site-library. I've triple-checked that I'm following the protocol as specified, but of course I could have missed something.

I serialized the bytes to disk for the server call that assigns the data.frame. It can be found here: https://dl.dropboxusercontent.com/u/10558029/encode.7z
Can someone else reproduce the behavior I'm seeing?

Issues with --RS-settings

  1. It won't allow to start in server mode, if used in combination with other cmd line parameters. It will only report the current settings, then stops. Apparently the same goes for --version. I expect it to report and continue, like --verbose does.
    Example: R CMD Rserve --version --slave --RS-conf ./Rserve.conf --RS-settings
  2. It doesn't properly report the applied config file.
    The documentation is saying that the /etc/Rserv.conf it's loaded anyway (which is somehow curious) but a command line config can overwrite some of the settings. It happens indeed, but config file that is being reported as used is still /etc/Rserv.conf. That is very confusing and very frustrating for new-comers.

I really hope to see these fixed. Not big ones, but definitely should improve adoption and flexibility.

Thx,
Lucian

Unrecognized escape in character string results in crash (Windows only)

Executing via Rserve the command:

try(eval(parse(text="setwd('Z:\sp\Dropbox\Prj\scilua\head')")),silent=TRUE)

results in a crash of Rserve(_d).exe due to the erroneous string escape:

C:\Users\sp\Documents\R\win-library\3.1\Rserve\libs\x64>Rserve_d.exe
Rserve 1.7-3 () (C)Copyright 2002-2013 Simon Urbanek
$Id$

Loading config file Rserv.cfg
Failed to find config file Rserv.cfg
Rserve: Ok, ready to answer queries.
 - create_server(port = 6311, socket = <NULL>, mode = 0, flags = 0x4000)
INFO: adding server 0000000000509A00 (total 1 servers)
INFO: accepted connection for server 0000000000509A00, calling connected
connection accepted.
sending ID string.

header read result: 16
DUMP [16]: 03 00 00 00 4f 00 00 00 00 00 00 00 00 00 00 00  |....O...........
loading buffer (awaiting 79 bytes)
parsing parameters (buf=0000000000519EA0, len=79)
DUMP [79]: 04 4b 00 00 74 72 79 28 65 76 61 6c 28 70 61 72 73 65 28 74 65 78 74 3d 22 73 65 74 77 64 28 27 5a 3a 5c 73 70 5c 44 72 6f 70 62 6f 78 5c 50 72 6a 5c 73 63 69 6c 75 61 5
c 68 65 61 64 27 29 22 29 29 2c 73 69 6c 65 6e 74 3d 54 52 55 45 29  |.K..try(eval(parse(text="setwd('Z:\sp\Dropbox\Prj\scilua\head')")),silent=TRUE)
PAR[0]: 0000004f (PAR_LEN=75, PAR_TYPE=4, large=no, c=0000000000519EA0, ptr=0000000000519EA4)
CMD=00000003, pars=1
parseString("try(eval(parse(text="setwd('Z:\sp\Dropbox\Prj\scilua\head')")),silent=TRUE)")
Error: '\s' is an unrecognized escape in character string starting ""setwd('Z:\s"

C:\Users\sp\Documents\R\win-library\3.1\Rserve\libs\x64>

On Linux and OSX Rserve shows the error but survives.

symlink clients -> src/client messing up installation from src/library/Recommended

Hi Simon,

not sure if you are creating this symlink, but the downloadable Rserve_1.8-1.tar.gz tarball from CRAN contains a symlink
clients -> src/client
which messed up my attempts to get it to install under R-3.1.1 on linux as a Recommended package during initial R build-from-source. The untar2 built-in function gets confused by the symlink and leaves us in the wrong /tmp directory after untaring, instead of the original Recommended directory, and the R build crashes. Arg.

Anyway, I realize this is more of a packagers bug, but if you have any influence, could you direct this note to who does the packaging? Thank you. I know not everyone wants Rserve as a recommended package (fools!) but I do. :)

Jason

eval command by SEXP(XT_CLOS) returns null

When CMD_eval command is executed with "function(a = 'hello', b = 2) { rep(a, b) }" text string, it returns SEXP object as follows.

        {
            type: _.XT_CLOS,
            value: {
                formals: {
                    type: _.XT_LIST_TAG,
                    value: [
                        {
                            type: _.XT_ARRAY_STR,
                            value: ["hello"]
                        },
                        {
                            type: _.XT_SYMNAME,
                            value: "a"
                        },
                        {
                            type: _.XT_ARRAY_DOUBLE,
                            value: [2]
                        },
                        {
                            type: _.XT_SYMNAME,
                            value: "b"
                        }
                    ]
                },
                body: {
                    type: _.XT_LANG_NOTAG,
                    value: [
                        {
                            type: _.XT_SYMNAME,
                            value: "{"
                        },
                        {
                            type: _.XT_LANG_NOTAG,
                            value: [
                                {
                                    type: _.XT_SYMNAME,
                                    value: "rep"
                                },
                                {
                                    type: _.XT_SYMNAME,
                                    value: "a"
                                },
                                {
                                    type: _.XT_SYMNAME,
                                    value: "b"
                                }
                            ]
                        }
                    ]
                }
            }
        }

But when another eval command is executed with this SEXP object, then the result is null. I expected the same SEXP object to be returned, which is the behavior when other expression types are used.

Rserve stil crashes on Windows with invalid escapes sequences

Opening a new issue as the previous one (see #19) was closed while the issue is still present and I can't re-open it.

The link mentioned in the proposed resolution suggests to use option(error=function() NULL), you probably mean options(error=function() NULL).
That still doesn't work: the example below shows that even though the error option is set, Rserve still crashes on the invalid escape sequence.

C:\Users\sp\Documents\R\win-library\3.1\Rserve\libs\x64>Rserve_d.exe
Rserve 1.7-3 () (C)Copyright 2002-2013 Simon Urbanek
$Id$

Loading config file Rserv.cfg
Failed to find config file Rserv.cfg
Rserve: Ok, ready to answer queries.
 - create_server(port = 6311, socket = <NULL>, mode = 0, flags = 0x4000)
INFO: adding server 0000000000518360 (total 1 servers)
INFO: accepted connection for server 0000000000518360, calling connected
connection accepted.
sending ID string.

header read result: 16
DUMP [16]: 03 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00  |....W...........
loading buffer (awaiting 87 bytes)
parsing parameters (buf=0000000000518E40, len=87)
DUMP [87]: 04 53 00 00 74 72 79 28 65 76 61 6c 28 70 61 72 73 65 28 74 65 78 74 3d 22 63 61 70 74 75 72 65 2e 6f 75 74 70 75 74 28 6f 70 74 69 6f 6e 73 28 65 72 72 6f 72 3d 66 75 6
e 63 74 69 6f 6e 28 29 20 4e 55 4c 4c 29 29 22 29 29 2c 73 69 6c 65 6e 74 3d 54 52 55 45 29  |.S..try(eval(parse(text="capture.output(options(error=function() NULL))")),silent=TRUE
)
PAR[0]: 00000057 (PAR_LEN=83, PAR_TYPE=4, large=no, c=0000000000518E40, ptr=0000000000518E44)
CMD=00000003, pars=1
parseString("try(eval(parse(text="capture.output(options(error=function() NULL))")),silent=TRUE)")
buffer parsed, stat=1, parts=1
result type: 20, length: 1
R_tryEval(xp,R_GlobalEnv,&Rerror);
Calling R_tryEval for expression 1 [type=6] ...
Expression 1, error code: 0
expression(s) evaluated (Rerror=0).
String vector of length 0:
getStorageSize(0000000005387D60,type=16,len=0) = 4
result storage size = 5 bytes
stored 0000000005387D60 at 0000000005A7F048, 0 bytes
stored SEXP; length=8 (incl. DT_SEXP header)
OUT.sendRespData
HEAD DUMP [16]: 01 00 01 00 08 00 00 00 00 00 00 00 00 00 00 00  |................
BODY DUMP [8]: 0a 04 00 00 22 00 00 00  |...."...
reply sent.

header read result: 16
DUMP [16]: 03 00 00 00 5f 00 00 00 00 00 00 00 00 00 00 00  |...._...........
loading buffer (awaiting 95 bytes)
parsing parameters (buf=0000000000518E40, len=95)
DUMP [95]: 04 5b 00 00 74 72 79 28 65 76 61 6c 28 70 61 72 73 65 28 74 65 78 74 3d 22 63 61 70 74 75 72 65 2e 6f 75 74 70 75 74 28 73 65 74 77 64 28 27 5a 3a 5c 73 70 5c 44 72 6f 7
0 62 6f 78 5c 50 72 6a 5c 73 63 69 6c 75 61 5c 68 65 61 64 27 29 29 22 29 29 2c 73 69 6c 65 6e 74 3d 54 52 55 45 29  |.[..try(eval(parse(text="capture.output(setwd('Z:\sp\Dropbox\P
rj\scilua\head'))")),silent=TRUE)
PAR[0]: 0000005f (PAR_LEN=91, PAR_TYPE=4, large=no, c=0000000000518E40, ptr=0000000000518E44)
CMD=00000003, pars=1
parseString("try(eval(parse(text="capture.output(setwd('Z:\sp\Dropbox\Prj\scilua\head'))")),silent=TRUE)")
Error: '\s' is an unrecognized escape in character string starting ""capture.output(setwd('Z:\s"

Moreover the documentation suggests that Rserve runs in not-interactive mode (with default config) in Windows prior to 0.6-2, while I'm running Rserve 1.7-3.

Documentation improvement on webpage

Quoting http://www.rforge.net/Rserve/dev.html:

XT_ARRAY_INT     data: (n*4) int,int,.. 
XT_ARRAY_DOUBLE  data: (n*8) double,double,.. 
XT_ARRAY_STR     data: (?) string,string,.. 
XT_ARRAY_BOOL    data: (n) byte,byte,.. 

Notice that it leads one to think that these are all the same format, aside from element size. That's not the case: XT_ARRAY_BOOL includes an extra size field that needs to be written. From qap_decode.c:

case XT_ARRAY_BOOL:
{
    int vl = ptoi(*(b++));
    char *cb = (char*) b;
    val = allocVector(LGLSXP, vl);
    i = 0;
    while (i < vl) {
    LOGICAL(val)[i] = (cb[i] == 1) ? TRUE : ((cb[i] == 0) ? FALSE : NA_LOGICAL);
    i++;
    }
    while ((i & 3) != 0) i++;
    b = (unsigned int*) (cb + i);
}
*buf = b;
break;

/*...*/

case XT_ARRAY_DOUBLE:
    l = ln / 8;
    val = allocVector(REALSXP, l);
#ifdef NATIVE_COPY
    memcpy(REAL(val), b, sizeof(double) * l);
    b += l * 2;
#else
    i = 0;
    while (i < l) {
        fixdcpy(REAL(val) + i, b);
        b += 2;
        i++;
}
#endif
    *buf = b;
    break;

Note the extra undocumented int vl = ptoi(*(b++)); in XT_ARRAY_BOOL.

RS.eval wait=FALSE and ignore collection

Considering the case when I need to call a function on server side without fetching the results I can use RS.eval(..., wait=FALSE). But after that I cannot run another calls due to:

Error in RS.eval(rsc, x, wait = wait, lazy = lazy) : 
  uncollected result from previous command, remove first

Can I ignore collection and proceed with next call somehow?

Rserve install error

Red Hat Enterprise Linux Server release 6.3 (Santiago)
R version 3.2.2

Trying to install Rserve from rforge.net, but fails with error below. Thanks for any tip.

install.packages("/usr/lib64/R/library/Rserve_1.7-3.tar.gz", repos = NULL, type = "source")
R CMD INSTALL Rserve_1.7-3.tar.gzInstalling package into ‘/home/R/x86_64-redhat-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)

  • installing source package ‘Rserve’ ...
    ** package ‘Rserve’ successfully unpacked and MD5 sums checked
    checking whether to compile the server... yes
    checking whether to compile the client... no
    checking for gcc... gcc -m64 -std=gnu99
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc -m64 -std=gnu99 accepts -g... yes
    checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/wait.h that is POSIX.1 compatible... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for string.h... (cached) yes
    checking for memory.h... (cached) yes
    checking sys/time.h usability... yes
    checking sys/time.h presence... yes
    checking for sys/time.h... yes
    checking for unistd.h... (cached) yes
    checking for sys/stat.h... (cached) yes
    checking for sys/types.h... (cached) yes
    checking sys/socket.h usability... yes
    checking sys/socket.h presence... yes
    checking for sys/socket.h... yes
    checking sys/un.h usability... yes
    checking sys/un.h presence... yes
    checking for sys/un.h... yes
    checking netinet/in.h usability... yes
    checking netinet/in.h presence... yes
    checking for netinet/in.h... yes
    checking netinet/tcp.h usability... yes
    checking netinet/tcp.h presence... yes
    checking for netinet/tcp.h... yes
    checking for an ANSI C-conforming const... yes
    checking whether byte ordering is bigendian... no
    checking whether time.h and sys/time.h may both be included... yes
    checking for pid_t... yes
    checking vfork.h usability... no
    checking vfork.h presence... no
    checking for vfork.h... no
    checking for fork... yes
    checking for vfork... yes
    checking for working fork... yes
    checking for working vfork... (cached) yes
    checking return type of signal handlers... void
    checking for memset... yes
    checking for mkdir... yes
    checking for rmdir... yes
    checking for select... yes
    checking for socket... yes
    checking for srandomdev... no
    checking for library containing crypt... -lcrypt
    checking crypt.h usability... yes
    checking crypt.h presence... yes
    checking for crypt.h... yes
    checking for socklen_t... yes
    checking for connect... yes
    checking whether to enable IPv6... no
    checking for dlopen in -ldl... yes
    checking openssl/rsa.h usability... yes
    checking openssl/rsa.h presence... yes
    checking for openssl/rsa.h... yes
    checking for library containing RSA_generate_key... -lcrypto
    checking openssl/ssl.h usability... yes
    checking openssl/ssl.h presence... yes
    checking for openssl/ssl.h... yes
    checking for library containing SSL_CTX_load_verify_locations... -lssl
    configure: creating ./config.status
    config.status: creating src/Makevars
    config.status: creating src/client/cxx/Makefile
    config.status: creating src/config.h
    ** libs
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c RSserver.c -o RSserver.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c Rserv.c -o Rserv.o
    Rserv.c: In function ‘prepare_set_user’:
    Rserv.c:372: warning: ignoring return value of ‘chown’, declared with attribute warn_unused_result
    Rserv.c:375: warning: ignoring return value of ‘chown’, declared with attribute warn_unused_result
    Rserv.c: In function ‘Rserve_QAP1_connected’:
    Rserv.c:2342: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
    Rserv.c:3351: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
    Rserv.c:3358: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result
    Rserv.c: At top level:
    Rserv.c:388: warning: ‘fork_http’ defined but not used
    Rserv.c:403: warning: ‘fork_https’ defined but not used
    Rserv.c:418: warning: ‘fork_ws’ defined but not used
    Rserv.c: In function ‘Rserve_QAP1_connected’:
    Rserv.c:2256: warning: ‘exp’ may be used uninitialized in this function
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c base64.c -o base64.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c http.c -o http.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c md5.c -o md5.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c oc.c -o oc.o
    oc.c: In function ‘oc_new’:
    oc.c:72: warning: pointer targets in passing argument 1 of ‘sha1hash’ differ in signedness
    sha1.h:4: note: expected ‘const char ’ but argument is of type ‘unsigned char *’
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c qap_decode.c -o qap_decode.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c qap_encode.c -o qap_encode.o
    qap_encode.c: In function ‘QAP_storeSEXP’:
    qap_encode.c:185: warning: unused variable ‘i’
    qap_encode.c:203: warning: unused variable ‘i’
    qap_encode.c:294: warning: unused variable ‘i’
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c rsio.c -o rsio.o
    rsio.c: In function ‘rsio_read_msg’:
    rsio.c:159: warning: dereferencing type-punned pointer will break strict-aliasing rules
    rsio.c:208: warning: dereferencing type-punned pointer will break strict-aliasing rules
    rsio.c: In function ‘rsio_write’:
    rsio.c:243: warning: dereferencing type-punned pointer will break strict-aliasing rules
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c session.c -o session.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c sha1.c -o sha1.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c standalone.c -o standalone.o
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c tls.c -o tls.o
    tls.c: In function ‘new_tls’:
    tls.c:41: warning: assignment discards qualifiers from pointer target type
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c websockets.c -o websockets.o
    websockets.c: In function ‘WS_connected’:
    websockets.c:111: warning: unused variable ‘s’
    websockets.c: In function ‘WS_recv_data’:
    websockets.c:634: warning: unused variable ‘more’
    websockets.c: At top level:
    rserr.h:20: warning: ‘RSEprintf’ defined but not used
    gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -DRSERVE_PKG -I. -Iinclude -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c winembed.c -o winembed.o
    gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o Rserve.so RSserver.o Rserv.o base64.o http.o md5.o oc.o qap_decode.o qap_encode.o rsio.o session.o sha1.o standalone.o tls.o websockets.o winembed.o -lssl -lcrypto -ldl -lcrypt -L/usr/lib64/R/lib -lR
    /usr/bin/ld: /usr/local/lib64/libssl.a(s23_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib64/libssl.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *
    * [Rserve.so] Error 1
    ERROR: compilation failed for package ‘Rserve’
  • removing ‘/home/R/x86_64-redhat-linux-gnu-library/3.2/Rserve’
    Warning in install.packages :
    installation of package ‘/usr/lib64/R/library/Rserve_1.7-3.tar.gz’ had non-zero exit status

Allow running as service - Do not detach from parent process

I'm trying to run Rserve with daemon disable however it doesn't work as expected.

From available documentation I couldn't find any way how to force Rserve to behave as a standard Linux daemon, which could be managed by init.d or systemd. Start as normal process, don't detach and terminate on SIGTERM.

Publish Rserve Java Client to Maven Central

Dear all - Is there a chance to publish the java client continuously to maven central?
Currently there are older releases published at the repository and I was wondering, if the good work could be made available more consistently (http://search.maven.org/#search%7Cga%7C1%7CREngine)

Beside that, it would be nice having an OSGi bundle to put the RServe and REngine environments into an OSGi container. I've started some work based on a maven build. The Build creates a single output bundle containing all packages.
If you are interested, you can see the current status here: https://github.com/cemmersb/RCode

Please let me know, if you have considered the options of
(a) having a build in place that provisions the artifacts to the central maven repository
(b) creating an OSGi bundle to support OSGi environments

Point (b) could be also achieved via the current project build with a small addition of an OSGi MANFEST file.

Kind regards,

Christoph

R CMD Rserve mutate original pid into Rserve service

These are my assumptions:

  • R CMD Rserve will create new pid for a started service
  • docker image will be automatically closed when pid started from CMD will be closed

I assume because of the above the Rserve docker image gets automatically closed.
I've tried both ways but both are closed just after startup:

CMD ["R","CMD","Rserve","--no-save"]
CMD R CMD Rserve --no-save

I've manage to workaround the issue with:

CMD Rscript -e 'library(Rserve); run.Rserve()'

But I wonder if it could be managed on the R CMD Rserve level?

install.packages('Rserve',,'http://www.rforge.net/') fails with undefined reference to `pthread_atfork'

CentOS release 6.6 (Final) 64bit
R version 3.2.0

Trying to install Rserve from rforge.net, but fails with error below. Thanks for any tip.

install.packages('Rserve',,'http://www.rforge.net/')
[...]
/tmp/ccPjMmJS.o: In function `ioc_setup':
/tmp/Rtmp5OW6HC/R.INSTALL172242400c61/Rserve/src/ioc.c:187: undefined reference to `pthread_atfork'
collect2: ld returned 1 exit status
make: *** [server] Error 1
ERROR: compilation failed for package ‘Rserve’
* removing ‘/usr/lib64/R/library/Rserve’

Could we close RServe in R?

Hi,
The question show as title. Rconnection could be closed in Java, but Rserve couldn't be closed.
Is there a solution about it?

Another double symbol issue, this time with `self_args` via self.oobMessage

In Rserv.c, send_oob_sexp expects self_args to be set before it can be called. Upon initialization, this is the address (in Rserve_prepare_child):

self_args was set! 0x105a2b718

Then, upon checking the value, in send_oob_sexp,

self_args will be read! 0x107c48b78

A test case that exercises this issue is available on the tests directory of the ocap-oob-rserve-issue branch of rserve-js:

$ git clone [email protected]:cscheid/rserve-js.git
$ cd rserve-js
$ git checkout ocap-oob-rserve-issues
$ cd tests
$ ./run_all_tests.sh

Here, this results in:

self_args was set! 0x108511718
INIT!
UP!
stored  function (x) {
            console.log("This is a cap!");
            return 20 + x;
        }  at  7251482012
huh?
[1] "7251482012"
attr(,"class")
[1] "javascript_function"
self_args will be read! 0x10a734b78
Error in Rserve:::self.oobMessage(list(s, ...)) :
  OOB commands can only be used from code evaluated inside an Rserve client instance

(the "self_args" bits are just extra printing stuff I added to rserve).

I'd try to fix this myself, but I don't really know how :(

Wrong process id in pid file when Rserve being daemonized

Currently, if Rserve is requested to generate a pid file through command line argument or Rserv.conf, and is configured to be daemonized, the wrong pid would be written in the pid file as the pid file is generated before the server forked its daemon.
Also, remove of pid file on normal/graceful shutdown should be done.

Close unused connections

Lets say, that I opened 20 connections from Java, but then my application failed without closing them.
The current number of open connections on RServe equals 20
find / -name "conn*" -print | grep ".*tmp/Rserv/conn.*" | wc -l
> 20

Then I rerun my Java application and now which opened another 20 connections and now I have 40 connections.
find / -name "conn*" -print | grep ".*tmp/Rserv/conn.*" | wc -l
> 40

Is is somehow possible by RServe to detect such situation and cleanup resources?

RSA public key returned in CMD_keyReq response does not work

Somehow the public key returned in CMD_keyReq response does not match with the public key generated locally by openssl command from the private key.

The private key was generated with:
openssl genrsa -out server.key 4096

Then the public key was generated with:
openssl rsa -pubout -in server.key -outform der -out server_pub.key

In Rserv.c, i2d_RSAPublicKey function is used in rsa_gen_resp function, so I assume public key is returned in DER format and used "-outform der" above. The file size of server_pub.key is always 550 bytes, even when I repeated the above 2 commands.

However, the public key returned in CMD_keyReq response is 526 bytes and the keys does not match.

If I encrypt authkey, username, and password with the local public key, subsequent CMD_secLogin command will succeeed. But it fails to encrypt if the public key returned by the server is used.

Rserve daemon crashes with Java client

Hi,

I run Rserve in daemon mode in Linux environment and use the REngine Java client to connect the server. My problem is the following:

  • First I initialize a session with voidEvalDetach
  • I load a package in the R code with the library command
  • When I try to reconnect the session, the daemon stops without error

The reconnection works with simple code, but complex codes seems to cause problem.

Is there any possibility for one rserve's client to share workspace with another?

This question is a cross-post from stackoverflow (http://stackoverflow.com/questions/34017057/is-there-any-possibility-for-one-rserves-client-to-share-workspace-with-another)

I'd like replace RExcel with the Excelsi-R. Excelsi-R talks R via RServe, and RServe has this feature, that makes each client work in independent workspaces.

What I want is to actually share a single workspace between at least 2 simultaneously connected clients. One client would be run by Excelsi-R, and another by manually launched interactive R Session. That would allow me to interface with the Excelsi-R session in traditional way (say, in RStudio).

I don't need asynchronous computation; I'm perfectly happy if Excelsi-R would have to wait until a command issued by the other connection finishes, and vice versa; just like in the RExcel "foreground mode".

Is it possible?

The EOL Spaces Not Trimed When Reading Values from /etc/Rserv.conf

Hi Simon:

When Rserve reads configuration values from /etc/Rserv.conf, it doesn't trim the spaces at the end of the line.
For example, suppose the password file is '/foo/bar.pwdfile'. If I accidentally leave spaces at the end in the configuration, like this:
'pwdfile /foo/bar.pwdfile ' (an extra space at the end)
the Rserve will treat the password file as '/foo/bar.pwdfile ' (an extra space at the end). As a result, the file cannot be read successfully

Could it be handled by Rserve if possible ?

Thanks.

RServe loads R environment before chroot

I am trying to create a self-contained RServe in a chroot jail.
This works perfectly. However, the initial startup of RServe binds to the current /usr/lib64/R/ installation, even if the chroot environment contains another R installation.

This poses problems if the chroot environment has a different R version from the system R version.

RServe should scan the configuration file and execute any chroot before loading any other functions/libraries.

Support Rserve behind proxy/firewall/load-balancer by enabling socket keep-alive

When Rserve is deployed behind a proxy/firewall/load-balancer with short idle timeout (AWS has a default of 60 seconds) and application messages are transferred over the socket, the proxy/firewall/load-balancer will simply drop the connection, causing the R Session invalidate.
By adding a Keep-Alive Socket option, the user can enable socket keep-alives for the Rserve process.
A good implementation should enable keep-alive when needed through configuration (Rserv.conf) and should also enable overriding the keep-alive socket option details (time, interval & probes) for the Rserve process specifically.

Rserve hangs when control commands enabled in 1.8 and higher

Hi, I'm having issue with RServe 1.8 when control commands enabled. It is probably the same what was described in #25 but I created minimal crashing example. The error is that RServe stopped accepting new connections and uses 100% of processor (for ever).
rserve-hangs

I tested that issue occurs on 1.8.1 and 1.8.3 (I'm almost sure that it's also on 1.8.2). After I read your comment from #25 I downgraded to 1.7.3 and everything works.

Im running serve from RScript using

#load libraries so all connections will share them
library(Rserve)
library("yaml")
library("...")
(...)
library("....")

run.Rserve(debug = TRUE, remote = TRUE, control = TRUE, auth = FALSE, fileio = TRUE, maxinbuf=500000, args="--no-save")

Then I'm connecting using Java client with following Scala code

import org.rosuda.REngine.Rserve.RConnection
val host = "10.12.my.rservehost"
val port = 6311
val connToClose = new RConnection(host, port)
val connToSendFile = new RConnection(host, port)
//send file
val serverStream = connToSendFile.createFile("someFile.txt")
serverStream.write("sdkjskjdkasjdkasjkdjskajdksjkajksjd".getBytes)
serverStream.flush()
serverStream.close()
//close
connToSendFile.close()
connToClose.close()
//hang
val connToHang = new RConnection(host, port)

No control commands need to be executed. It is just enough to have opened connection 'A' before you send file via other connection and then close 'A' connection. It sometimes necessary to execute code twice or at most three times

(object-capability) two copies of library loaded at the same time causes oc_env to be NULL in oc_resolve

There's something weird in the ocap mode where oc_env appears to get reset to NULL (garbage collected? who knows) between calls to Rserve_oc_register and calls to oc_resolve. I've instrumented a version of rserve to spit out the pointer value of oc_env along the way, and this is what is looks like, roughly:

(inside Rserve_oc_register) oc_env value: 0x0
(inside oc_register) oc_env will be created!
(inside oc_register) oc_env value: 0x7fccf9858120
(inside oc_register) oc_env value: 0x7fccf9858120
(inside Rserve_oc_register) oc_env value: 0x7fccf9858120
Registered ocap with hash ywn4Nw9p1ey3XU6kXzZW.7wWJq_s
(inside oc_resolve) oc_env value: 0x0

The weird thing is that this doesn't happen everywhere (the bug above happens when running my own version of ocap-enabled rcloud). On my test suite over at rserve-js, oc_env is not reset:

(inside Rserve_oc_register) oc_env value: 0x0
(inside oc_register) oc_env will be created!
(inside oc_register) oc_env value: 0x7fb41aea3f80
(inside oc_register) oc_env value: 0x7fb41aea3f80
(inside Rserve_oc_register) oc_env value: 0x7fb41aea3f80
Registered ocap with hash PCy0Y_Ls58aLT0FlMzJKBV3NshFw
(inside oc_resolve) oc_env value: 0x7fb41aea3f80
INIT!
...

... and so on. I don't know what could be causing this, or I'd be more specific, sorry.

Rserve logs

Is there any place where Rserve can store it's logs? as the regular server application.
Searching for "log" does not find anything in documentation, faq, technical info. No luck in R CMD Rserve --help too. It could be any logs, errors from Rserve sessions or a logs from Rserve daemon itself.

Rserv.c does not check the result of fork for errors

In the Rserve_QAP1_connected function in Rserve.c, the RS_fork call is not checked for errors. If the return value is -1 than the fork has failed and errno will be set. I discovered the problem by executing code on the server via the --RS-source option to load a large dataset into memory. Importantly, that dataset took up more than 50% of the systems memory. Thus any attempt to fork the process at that point will fail with an "cannot allocate memory" error (generally, it actually depends on a few kernel settings). Rserve does not catch this error however and in the end it manifests as the client simply refusing to connect with the error:

RSconnect()
Error in RSconnect() :
Attempt to connect to Rserve timed out, connection closed

Which does not indicate the real problem at all.

Rserver textual output using sink command

Is it safe to use the sink command to capture output from R in RServer? Is each request completely isolated so that each sink connection would be independent? (there is a warning in the sink documentation about reusing connections so was just wondering how it might be affected when run within RServer).

No partial message support with websockets

Websockets support partial messages on the protocol level. If the message is bigger than maxsendbuf, the server should send in maxsendbuf sized chunks. Currently you get an object too big error (code 4C). Try setting maxsendbuf to 64 (kB) as a test.

short rownames representation in R

This is my code:

final RConnection c = new RConnection();
String makeIntOverflow = "makeIntOverflow <- function(x){" +
                "   abshauf <- table(x);" +
                "   lg <- length(abshauf);" +
                "   refheuf <- abshauf / lg;" +
                "   mydata <- c(abshauf, refheuf);" +
                "   dim(mydata) <- c(lg,2); " +
                "   mydata <- data.frame(table(x), mydata); " +
                "   return (mydata); " +
            "}" ;
c.eval(makeIntOverflow);
REXP eval = c.eval("makeIntOverflow( c(1,1,1,1,1,0,0,0) );");
REXP rowName = eval.getAttribute("row.names");
int[] asInt = rowName.asIntegers();
for (int i = 0; i < asInt.length ; ++i){
    System.out.print(asInt[i]+"\n");
}

As I execute the R-Code directly in R, as

makeIntOverflow <- function (){....}
makeIntOverflow( c(1,1,1,1,1,0,0,0) );

I get the row name as "1" and "2".
As I execute the above Java code, I get the rowNames as an int[] of {-2147483648, -2}, which is
obviously not expected. Have you mayby an workaround for this?
(-2147483648 = -2^31)

tempfile() fails when using "su client", Permission denied because tempdir() belongs to root

When R starts up it creates a temporary directory, which is a default argument for the tempfile() function. With Rserve configuration set to "su client", tempdir() directory is owned by root, and client code, running as the non-root user, fails with "Permission denied" when using tempfile() without overriding the tmpdir parameter.

It appears the set.tempdir() function should be called somewhere along the line.

Unable to reattach to a session

I'm having a weird issue with reattaching to a detached session created with RSevalDetach using the RSclient (issue also pops up using the java client with voidEvalDetach()), when I try to reattach the server closes connection with garbage message. This only seems to happen when I'm doing something with one of bioconductor's annotation packages and happens every time. Here's a simple snippet to reproduce my issue:

RSattach(RSevalDetach (RSconnect(),
  "rr<-(function (geneList, minGSSize, pvalueCutoff, pAdjustMethod, organism='human') {
    library (org.Hs.eg.db);
    GStoEG_map <- as.list (org.Hs.egALIAS2EG);
    require(ReactomePA);
    EntrezList = lapply (na.omit (geneList), function (GS, GStoEG_map) GStoEG_map[[GS]][1], GStoEG_map = GStoEG_map);
    enrichPways <- enrichPathway (gene = EntrezList, minGSSize = minGSSize, organism = organism, pvalueCutoff = pvalueCutoff, pAdjustMethod = pAdjustMethod, readable = T);
    summary (enrichPways);
  }) (c ('C1S', 'IDO1', 'IL8', 'HLA-DRA', 'NLRC5', 'TNF', 'CD274', 'COL4A1', 'CLIC2', 'SECTM1', 'GBP4','SOCS3', 'UBE2L6', 'IL18BP', 'EPSTI1', 'SLC6A14','SAMD9L', 'CCL22', 'DRAM1', 'HLA-DPA1', 'CX3CL1'), 20, .25, 'fdr');"))

The error message on the server with debug on is:

session: resuming session, waiting for connections.
session: accepted
OUT.sendRespData
HEAD DUMP [16]: 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00  |................
(no body)
reply sent.
malformed packet (n=-1). closing socket to prevent garbage.
done.

This is all with R version 3.2.0; CRAN's version of Rserve, the libraries needed from bioc are org.Hs.eg.db and ReactomePA; Rserve is running on locahlost at port 6311

CMD_readFile response is not encoded as DT_bytestream

Documentation (http://rforge.net/Rserve/dev.html) says that response for CMD_readFile command is a DT_bytestream, so the response should have 16 bytes of the message header, followed by 4 or 8 bytes of parameter header starting with DT_bytestream = 5, followed by the rest of the data.

However, when I do

  • Send CMD_eval with a string parameter write.csv(cars, 'cars.csv') to the server
  • Send CMD_openFile with a string parameter cars.csv to the server
  • Send CMD_readFile with an integer parameter 128 to the server,

I receive the following response:

  • 16 bytes of message header - [65537 128 0 0] (showing as 32-bit integers here), followed by
  • 4 bytes of message body [34 34 44 34], which is essentially ""," - first 4 bytes of cars.csv

If this indeed the expected behavior, shouldn't the documentation be fixed to match?

It would also be nice to move documentation to github at some point.

Is it possible to share loaded packages accross Rserve sessions ?

I'm new to RServe which I use on linux via a Java API. It's RServe 1.8.1

I noticed that across different sessions, needed R packages are each time reloaded (which takes time).

I wonder if there are various possibilities to load packages once for all and share them across all sessions.

Some guesses :

  1. As I start RServe from R, I could maybe load libaries before calling run.Rserve, but that would not be a good solution as in my application, I don't know before starting the server which packages will be needed
  2. I noticed the function self.ctrlEval, could it be called from a session to load on the server some packages which will be then accessible to subsequent sessions ?

Need Updated Documentation

I've noticed some great work has gone into RServe over the past few years but I feel like the documentation has not been kept up very well. For example, the New/Changelog shows some great stuff for 1.8-3 (I think). But I dont really understand what these things are:

What does a Rserve.context() actually do? Could we get an example?

"added WebSockets/QAP proxy and HTTP server. It is a stand-alone program that can be used to separate the R process from the network to enhance security" Are these 2 different things? Or one new feature? How do I start this stand-alone program? HOW can I use it to enhance security? It looks like maybe it starts automatically but its not really clear. An example would be great.

As someone who is trying to champion my company in using R and specifically RServe for some of our applications, I'd love to have a bit better documentation. Thanks for all that you do.

Cannot install Rserve, clang error

Using just R (not RStudio), I tried

install.packages("Rserve")

I received a handful of warnings (3 of them), but only one error:

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [server] Error 1
ERROR: compilation failed for package ‘Rserve’
* removing ‘/usr/local/lib/R/3.2/site-library/Rserve’

If the warnings are useful:

  1. clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/include -DRSERVE_PKG -I. -Iinclude -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/include -fPIC -g -O2 -c Rserv.c -o Rserv.o

    Rserv.c:2976:16: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if (fbufl < 0) fbufl = sfbufSize;

  2. clang -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/include -DRSERVE_PKG -I. -Iinclude -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/include -fPIC -g -O2 -c oc.c -o oc.o

    oc.c:72:11: warning: passing 'unsigned char [64]' to parameter of type 'const char *' converts between pointers to
    integer types with different sign [-Wpointer-sign]
    sha1hash(rbuf, sizeof(rbuf) - 1, hash);

    ./sha1.h:4:27: note: passing argument to parameter 'buf' here
    void sha1hash(const char *buf, int len, unsigned char hash[20]);

  3. clang -DSTANDALONE_RSERVE -DDAEMON -I. -Iinclude -I/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/include -DNDEBUG -I/usr/local/include -DRSERVE_PKG -I. -Iinclude -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -I/usr/local/include -fPIC -g -O2 -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -g -O2 -DRSERVE_PKG -I. -Iinclude -o Rserve standalone.c md5.c session.c qap_decode.c qap_encode.c sha1.c base64.c websockets.c RSserver.c tls.c http.c oc.c rsio.c -ldl -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation -ldl

    In file included from standalone.c:6:
    ./Rserv.c:2976:16: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if (fbufl < 0) fbufl = sfbufSize;

    oc.c:72:11: warning: passing 'unsigned char [64]' to parameter of type 'const char *' converts between pointers to
    integer types with different sign [-Wpointer-sign]
    sha1hash(rbuf, sizeof(rbuf) - 1, hash);

    ./sha1.h:4:27: note: passing argument to parameter 'buf' here
    void sha1hash(const char *buf, int len, unsigned char hash[20]);


Here are some software & computer specs:

Mac:

System Software Overview:

  System Version:   OS X 10.11.1 (15B42)
  Kernel Version:   Darwin 15.0.0
  Boot Volume:  Macintosh HD
  Boot Mode:    Normal
  Computer Name:    Mike's Mac
  User Name:    Mike Williamson (mike)
  Secure Virtual Memory:    Enabled
  Time since boot:  3 days 2:11

R:

> R.Version()
$platform
[1] "x86_64-apple-darwin15.0.0"

$`svn rev`
[1] "69053"

$version.string
[1] "R version 3.2.2 (2015-08-14)"

$nickname
[1] "Fire Safety"

Thanks!

Rserve instances locked

Hi, I'm facing a weird problem: I have a ruby client talking to Rserve, and sometimes (randomly, once or twice in a day) the connection raise a Timeout exception, and from that moment all the commands passed to Rserve are not responding.

I have to manually restart the app, so it re-connects with Rserve.

Do you know where do I have to look? I'm very blind, there's no logs indicating the problem.

Outputs "Rserve started in non-daemon mode." for each request

When started in non-daemon mode with silent option, Rserve outputs "Rserve started in non-daemon mode." for each request.

E.g. launch command:

R CMD Rserve --silent --vanilla --max-ppsize=100000 --RS-conf Rserve.conf --RS-port 8888

Output after 3 requests:

Rserve started in non-daemon mode.
[1] "Raw parameters: [120,4]"
[1] "Parsed parameters: 120" "Parsed parameters: 4"  
[1] "Result 30"
[1] "Result as JSON [     30 ]"
Rserve started in non-daemon mode.
[1] "Raw parameters: [120,6]"
[1] "Parsed parameters: 120" "Parsed parameters: 6"  
[1] "Result 20"
[1] "Result as JSON [     20 ]"
Rserve started in non-daemon mode.
[1] "Raw parameters: [120,3]"
[1] "Parsed parameters: 120" "Parsed parameters: 3"  
[1] "Result 40"
[1] "Result as JSON [     40 ]"

This seems to be an inverted condition in standalone.c:

} else if (rs_silent) puts("Rserve started in non-daemon mode.");

--RS-pidfile is undocumented

FWIW it seems to be functional, just not sure how you're expected to find the option actually exists though :-/

$ 
R CMD Rserve --help
Usage: R CMD Rserve [<options>]

Options: --help  this help screen
 --version  prints Rserve version (also passed to R)
 --RS-port <port>  listen on the specified TCP port
 --RS-socket <socket>  use specified local (unix) socket instead of TCP/IP.
 --RS-workdir <path>  use specified working directory root for connections.
 --RS-encoding <enc>  set default server string encoding to <enc>.
 --RS-conf <file>  load additional config file.
 --RS-settings  dumps current settings of the Rserve
 --RS-source <file>  source the specified file on startup.
 --RS-enable-control  enable control commands
 --RS-enable-remote  enable remote connections

All other options are passed to the R engine.
$ 
R CMD Rserve --version
Rserve v1.7-3 ()
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"

Can't compile Rconnection in clients/cxx

struct phdr { /* always 16 bytes */
    int cmd; /* command */
    int len; /* length of the packet minus header (ergo -16) */
    int dof; /* data offset behind header (ergo usually 0) */
    int res; /* high 32-bit of the packet length (since 0103
                and supported on 64-bit platforms only)
                aka "lenhi", but the name was not changed to
                maintain compatibility */
};
struct phdr {   /* always 16 bytes */
    int cmd;    /* command */
    int len;    /* length of the packet minus header (ergo -16) */
    int msg_id; /* message id (since 1.8) [WAS:data offset behind header (ergo usually 0)] */
    int res; /* high 32-bit of the packet length (since 0103
                and supported on 64-bit platforms only)
                aka "lenhi", but the name was not changed to
                maintain compatibility */
};

struct phdr in Rsrv.h was changed.
But Rconnection.cc still use dof.

    head.dof=ptoi(head.dof);
    head.res=ptoi(head.res);
    if (head.dof>0) { // skip past DOF if present
            char sb[256];
        int k=head.dof;
        while (k>0) {
            n=recv(s,(char*)sb,(k>256)?256:k,0);
            if (n<1) {
                closesocket(s); s=-1;
                return -8; // malformed packet
            }
            k-=n;
        }
    }

Is rserve interrupt working for Windows?

Hi!
I'd like to confirm if rserve can be interrupted(not killed) in windows properly.
I've searched your repository for SIGINT occurrences and see some expressions like #ifdef unix.
I'm not sure but maybe rserve won't handle SIGINT in windows?

I start rserve by run.Rserve(...) and it will be interrupted in unix if needed using: kill -SIGINT pid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.