我正在使用谷歌云平台上的rstudio pro上的plumber。下面的代码在我的本地机器上运行良好,即我可以在提供的链接上查看swagger UI,但不能在google云平台上运行。
# plumber.R
#' Echo the parameter that was sent in
#' @param msg The message to echo back.
#' @get /echo
function(msg="")
{
list(msg = paste0("The message is: '", msg, "'"))
}
#' Plot out data from the iris dataset
#' @param spec If provided, filter the data to only this species (e.g. 'setosa')
#' @get /plot
#' @png
function(spec)
{
myData <- iris
title <- "All Species"
# Filter if the species was specified
if (!missing(spec))
{
title <- paste0("Only the '", spec, "' Species")
myData <- subset(iris, Species == spec)
}
plot(myData$Sepal.Length, myData$Petal.Length,
main=title, xlab="Sepal Length", ylab="Petal Length")
}我运行管道工脚本并得到以下输出
> pr$run(port = 8000 )
Starting server to listen on port 8000
Running the swagger UI at http://127.0.0.1:8000/__swagger__/当我使用上面的链接时,我得到了下面的错误,尽管它在我的本地应用程序上运行良好
HTTP Error 404. The requested resource is not found.管道工文档,建议检查是否有防火墙,因为我们在远程服务器上运行,但在谷歌云上我找不到任何防火墙规则阻止这一点。
请建议我该怎么做。
发布于 2019-06-07 21:38:28
http://127.0.0.1是您的本地主机。当您在云中运行时,您必须使用RStudio专业版实例的云机器的ip,并确保它对您公开和可用。此外,管道工只接受http请求,因此您的云机器必须接受http请求。
您是否在使用市场上的vm?
https://stackoverflow.com/questions/56395317
复制相似问题