首页 > 解决方案 > 错误:未找到合适的服务器(`serverSelectionTryOnce` 设置):[socket timeout calls ismaster on ...]

问题描述

我想知道为什么 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 的日子不好过。

用户界面

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
    })

})

标签: rmongodbshinyshinyappsmongolite

解决方案


你现在可以试试。可能是 MongoDB 或 shinyapps.io 存在一些问题。而是第二个。现在一切正常。


推荐阅读