rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 256 forks source link

unable send response for GET requests and not able to load Swagger UI in server #237

Closed chinthanishanth closed 6 years ago

chinthanishanth commented 6 years ago

i am creating API's using plumber to integrate R output to web application in my current company. i am able to send response for POST requests , but for GET requests i am getting error:

["{\"status\":[500],\"summary\":[\"ERROR: lexical error: invalid char in json text.\\n NA\\n (right here) ------^\\n\"]}"]

and i am getting same above error while loading swagger UI

http://<serverip>:8000/__swagger__/

in my personal PC i am able to send response for GET & POST requests and able to load swagger UI, but in server i am getting above error

sample R plumber Script in server:

plumber.R

library(plumber)
r = plumb("./Main.R")
r$setErrorHandler(function(req,res,e){print("error executed");result <- jsonlite::toJSON( list(status = 500,summary =paste("ERROR: ",conditionMessage(e))));result})
r$run(host= "0.0.0.0",port=8000,swagger = T)

Main.R

#* @get /test
gettest<- function(){
  varble <- "get request test"
  return(varble)
}

sessioninfo

R version 3.4.3 (2017-11-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                  LC_TIME=en_US.UTF-8          
 [4] LC_COLLATE=en_US.UTF-8        LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8           LC_ADDRESS=en_US.UTF-8       
[10] LC_TELEPHONE=en_US.UTF-8      LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] jsonlite_1.5  RJDBC_0.2-7   DBI_0.7       rJava_0.9-9   plumber_0.4.4

loaded via a namespace (and not attached):
[1] compiler_3.4.3 R6_2.2.2       tools_3.4.3    Rcpp_0.12.15   crayon_1.3.4   stringi_1.1.6 
[7] httpuv_1.3.5  
trestletech commented 6 years ago

in my personal PC i am able to send response for GET & POST requests and able to load swagger UI, but in server i am getting above error

Can you help me understand the difference between the two environments? Is the session info from your local or remote environment? How are you hosting the app?

chinthanishanth commented 6 years ago

Can you help me understand the difference between the two environments? Is the session info from your local or remote environment?

That is from remote environment

How are you hosting the app?

we took dedicated servers from OVH and installed r and rstudio server (free version )

Actually it was my mistake we are not able ping server ip. thanks for your time and replay. plumber was one among greatest r packages. we are looking forward for asynchronous support from plumber .. so that we can handle multiple requests at once ...may i know when will be the next version of plumber released with asynchronous support?

trestletech commented 6 years ago

Thanks for the kind words. I'm hoping to start working on support for promises here in the next few months.