5

I would like to build a simple webserver using Rook, however I am having strange errors when trying it in R-Studio:

The code

library(Rook)
s <- Rhttpd$new()
s$start()
print(s)

returns the rather useless error

"Error in listenPort > 0 : comparison (6) is possible only for atomic and list types".

When trying the same code in a simple R-Console,everything works - so I would like to understand why that happens and how I can fix it.

RStudio is Version 0.99.484 and R is R 3.2.2

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Christian Sauer
  • 10,351
  • 10
  • 53
  • 85
  • 2
    The `httpuv` package has an implementation of the Rook spec which works much better than the original. Try [webutils::demo_httpuv()](https://github.com/cran/webutils/blob/master/R/demo_httpuv.R) for a quick demo of how to use it. – Jeroen Ooms Sep 29 '15 at 12:21

1 Answers1

7

I've experienced same thing.

TLDR: This pull request solves the problem: https://github.com/jeffreyhorner/Rook/pull/31


RStudio is treated in different way and Rook port is same as tools:::httpdPort value. The problem is that in current Rook master tools:::httpdPort is assigned directly. It's a function that's why we need to evaluate it first.


If you want to have it solved right now, without waiting for merge into master: install devtools and load package from my fork @github.

install.packages("devtools")
library(devtools)
install_github("filipstachura/Rook")
Filip
  • 478
  • 4
  • 8