r-错误:找不到合适的服务器("serverSelectionTryOnce"集):[socket



我想知道为什么shinyapps.io不能再从Atlas连接到mongoDB。我使用mongoAtlas和shinyapps.io.做了无数个项目

截至今天,我发布的任何新应用程序都不允许我连接到我的mongoDB。

在我的日志中,我得到一个错误:找不到合适的服务器(serverSelectionTryOnce集(:[socket timeout calling 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
})
})

您现在可以尝试了。可能是MongoDB或shinyapps.io出现了一些问题,而不是第二个问题。现在一切正常。

最新更新