Diwakar Pant
Diwakar Pant

Reputation: 21

"Node Stack Overflow" error while running R script on Plumber

I am trying to create a REST web API using plumber package in R.first time it runs fine but second time when we run the same code it's showing the "node stack overflow" error. I just try to print the same message from my function. Code is given in the next section

I have also tried running it on VMWare linux (Ubuntu) by allocating it additional memory (initially 8192 kb and then 7969177 kb. However the result has always been the same error

    # plumber.R
    #' Echo the parameter that was sent in
    #' @param msg The message to echo back.
    #' @get /echo
       function(msg="")
        {
          list(msg = paste0 ("The message is: '", msg, "'"))
        }
       library('plumber')
      plumber::plumb("plumber.R")$run

Upvotes: 1

Views: 1183

Answers (2)

metales
metales

Reputation: 11

remove the first line "# plumber" and every thing will work perfectly.

Upvotes: 0

wishy
wishy

Reputation: 23

Create one file in R and name it myfile.R in a folder create another file name it plumb.R both file should be in same folder or working dir

for myfile.R write this code

# myfile.R
#' @get /mean
#' 
normalMean <- function(samples=10){
  data <- rnorm(samples)
  mean(data)
}

In plumb.R write

library(plumber)

r <- plumb("myfile.R")
r$run(port=8000)

After that open your google browser and type as follows http://localhost:8000/mean

Simple it will give you output

Upvotes: 1

Related Questions