Search code examples
ramazon-web-servicesapiamazon-ec2restrserve

How to reach a restrserve api from rstudio server on aws?


I am trying out the very interesting package RestRserve from with RStudo server that I installed on an AWS instance.

This is de code I use:

library(RestRserve)
app = Application$new()
app$add_get(
  path = "/hello", 
  FUN = function(request, response) {
    response$set_body("Hello from RestRserve")
  })
backend = BackendRserve$new()
backend$start(app, http_port = 8080)

I think the app is up and running, the message seems right:

{"timestamp":"2020-01-26 07:42:30.957686","level":"INFO","name":"Application","pid":1872,"msg":"","context":{"http_port":8080,"endpoints":{"HEAD":"/hello","GET":"/hello"}}}
-- running Rserve in this R session (pid=1872), 2 server(s) --
(This session will block until Rserve is shut down)

However, when I try to reach the app using the ip address of the instance like this: http://35.180.45.129/hello the browser says the site can't be reached.

Did I miss something? Any ideas about why this doesn't work?


Solution

  • Likely you need two additional steps:

    • make sure you allow traffic from internet to 8080 port
    • make sure you use public IP (or better DNS) of your instance