【发布时间】:2020-02-19 07:10:42
【问题描述】:
我想知道为什么 shinyapps.io 不能再从 Atlas 连接到 mongoDB。我使用 mongoAtlas 和 shinyapps.io 完成了无数项目。
截至今天,我发布的任何新应用都不允许我连接到我的 mongoDB。
在我的日志中,我收到一个错误:
找不到合适的服务器(serverSelectionTryOnce 设置):[socket timeout calls ismaster on 'cluster0-shard-00-00-02dsl.mongodb.net:27017']
代码在 Rstudio Cloud、我的本地电脑和我朋友的本地电脑上完美运行。但是shinyapps.io 的日子不好过。
UI.R
library(mongolite)
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
tableOutput("table")
)
)
))
服务器.R
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
url = "mongodb://jwrong:<mypass>@cluster0-shard-00-00-02dsl.mongodb.net:27017,cluster0-shard-00-01-02dsl.mongodb.net:27017,cluster0-shard-00-02-02dsl.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=false"
df.orats = mongo(collection = "df.orats", db = "test", url = url, verbose = T)
d = df.orats$find()
output$table <- renderTable({
d
})
})
【问题讨论】:
-
你检查IP白名单了吗(可能是你的服务器IP被改变了)?
-
嗨@Neodan,我确实检查了我的白名单。我目前将其设置为 0.0.0.0/0 以确保 shinyserver 可以访问它。您能否再解释一下(如果您认为我应该将其设置为不同的东西)。谢谢
-
我多次遇到此问题,已检查所有端口并允许所有 IP 地址。但问题仍然存在,因为错误:找不到合适的服务器(
serverSelectionTryOnce设置):[套接字超时调用 ismaster ...
标签: r mongodb shiny shinyapps mongolite