rstudio / plumber

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

Not able to use swagger URL after deployed #786

Open aspergillus opened 3 years ago

aspergillus commented 3 years ago

I have deployed plumber on our own CentOS 7 server using pm2 but unable to use swagger after deploy .

With this script have deployed plumber pm2 start --interpreter="Rscript" /var/www/html/start_API/callapi.R

callapi.R

#!/usr/bin/env Rscript

library(plumber)
plumber::plumb("./start_API/gwas_plumber.R")$run(port = 9000, host = "0.0.0.0")

pm2 status

 id  │ name       │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ callapi    │ default     │ N/A     │ fork    │ 26366    │ 0s     │ 0    │ online    │ 0%       │ 10.0mb   │ web-app│ disabled

pm2 log

/.pm2/pm2.log last 15 lines:
PM2        | 2021-03-25T06:02:36: PM2 log: App [callapi:0] starting in -fork mode-
PM2        | 2021-03-25T06:02:36: PM2 log: App [callapi:0] `online`
/.pm2/logs/callapi-error.log last 15 lines:
0|callapi  | Running plumber API at http://0.0.0.0:9000
0|callapi  | Running swagger Docs at http://127.0.0.1:9000/__docs__/

I have tried reinstalling the swagger and plumber with its dependencies, swagger = TRUE

JS script from where I have to send request to plumber xhr.open('GET', 'http://127.0.0.1:4409/Query?query=${userquery}&input=${this.selectedAdvance}');

Trying to send xhr request to plumber but getting error always why?????

When run API locally I get two URL. one for plumber and one for swagger in the system netstat and When run API on Server I get only one URL which is for plumber. why this happens?????

schloerke commented 3 years ago

Are you mounting anything at /?

Can you show me the printed output of your api? Ex: print(plumber::plumb("./start_API/gwas_plumber.R"))

aspergillus commented 3 years ago

Plumber router with 3 endpoints, 4 filters, and 0 sub-routers.

Call run() on this object to start the API.

├──[queryString] ├──[body] ├──[cookieParser] ├──[sharedSecret] ├──/Query (GET) ├──/GetData (GET) └──/gene_and_snp (GET)

meztez commented 3 years ago

Do you have any firewall rules in place? Can you provide a reproducible environment where the problem happens? I was not able to reproduce with a digital ocean droplet. Maybe a Dockerfile?

aspergillus commented 3 years ago

Yes, We have a firewall rules. So till now we haven't open the port from the server. Do we have to open the port for plumber to test our application on server too?