'Plumb error to set local host in R programming
I'm writing some toy APIs on Plumber in order to get familiar with this tool. Reading various tutorials and documentations to set the local host, it is recommended these lines
library(plumber)
r = plumb("Apitest.R")
r$run(port = 1030, host = "0.0.0.0") # or r$run(port=8000)
#* Return the multiplication of two numbers
#* @param a Multiplier
#* @param b Multiplicand
#* @post /multiplication
function(a, b){
as.numeric(a) * as.numeric(b)
}
when I run the code (with r$run(port = 1030, host = "0.0.0.0") or with r$run(port=8000)) I get this error:
> plumb(file='APItest.R')$run()
Error in stopOnLine(lineNum, file[lineNum], e) :
Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e): Error on line #4: '' - Error in stopOnLine(lineNum, file[lineNum], e
Solution 1:[1]
I faced a similar issue recently. Unfortunately the error message is not very helpful and this behavior is not well documented. In my case the problem was I was calling r$run(foo) from the same script that had the endpoint defined and this was causing the recursion problem. Hope this helps someone.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | oropo |
