3

I have saved one R script with name MC_APIv1.1-Prod.R in Jupyterlab and when I run the following code in R Console of Jupyterlab :

plumber::plumb("MC_APIv1.1-Prod.R")$run(host = "0.0.0.0", port = 5763,swagger = TRUE)

It gives the following message:

Running plumber API at http://0.0.0.0:5763

Running swagger Docs at http://127.0.0.1:5763/__docs__/

But I can't see the swagger UI while kernel is still running. When I run this code in RStudio then I can see the swagger window and it shows the plot in the browser window but it is not working in my case.

Can anyone please explain what is happening here and how to resolve this issue. Any help would be appreciated.

Complete code for the mentioned R file is here.

ankit
  • 277
  • 1
  • 4
  • 25
  • where is this Jupyter lab hosted? (local computer or server?) I was able to load the swagger UI on my local without any issues by calling the second url `http://127.0.0.1:5763/__docs__/` in my browser. – jav Sep 21 '22 at 02:35
  • @jav it is hosted on server – ankit Sep 21 '22 at 06:08

2 Answers2

2

The docs endpoint is only open for access from the local machine as the url is 127.0.0.1.

The swagger argument is deprecated according to docs https://www.rplumber.io/reference/Plumber.html?q=swagger#method-run-

try with

plumber::plumb("MC_APIv1.1-Prod.R")$run(host = "0.0.0.0", port = 5763, docs="swagger")

or

plumber::plumb("MC_APIv1.1-Prod.R")$set_docs("swagger")$run(host = "0.0.0.0", port = 5763)

Giorgos
  • 156
  • 4
1

Maybe check this direction:

https://stackoverflow.com/questions/1694144/can-two-applications-listen-to-the-same-port#:~:text=Yes.,whichever%20one%20they%20need%20to.

The message you're receiving might imply that the port cannot be occupied by both simultaneously. By showing you plumber and swagger being at 5763.

Shalofty
  • 29
  • 4