Closed akeever2 closed 7 months ago
I have the same problem. I have been connecting to a database before the app starts, then disconnecting in an onStop function within the server. After adding the login stuff, my database connection is closed after the login because the session stops. It seems to me that a new session immediately starts, because the UI still works (e.g. in the example below), but by that time my database connection has been closed. Maybe there's a better way to handle the database connections to avoid this problem in the first place. But I thought I would chime in here with a smaller reproducible example in case it's helpful:
library("shiny")
library("shinymanager")
# Init DB using credentials data
credentials <- data.frame(
user = c("user1"),
password = c("user1"),
admin = c(FALSE),
stringsAsFactors = FALSE
)
ui <- fluidPage("Example app",
selectInput("number", "Pick a number", choices = c(1,2,3)),
textOutput("number_chosen")
)
ui <- secure_app(ui, enable_admin = TRUE)
server <- function(input, output, session) {
result_auth <- secure_server(check_credentials = check_credentials(credentials))
output$res_auth <- renderPrint({
reactiveValuesToList(result_auth)
})
output$number_chosen <- renderText({
paste("You picked:", input$number)})
onStop(function() {
# Here I disconnect from a database
print("Session stopped")
})
}
shinyApp(
ui,
server,
onStart = function() {
onStop(function() {
print("Application exit")
})
}
)
Have you read and try on README part "troubleshooting" ?
I have a shiny app to generate reports. It was working correctly until I added the password authentication. Now immediately after login it produces the following warnings and ends my session:
Listening on http://127.0.0.1:3679 The name provided ('sign-out') is deprecated in Font Awesome 5: please consider using 'sign-out-alt' or 'fas fa-sign-out-alt' instead use the
verify_fa = FALSE
to deactivate these messages This Font Awesome icon ('close') does not exist: if providing a customhtml_dependency
thesename
checks can be deactivated withverify_fa = FALSE
Session Ended Warning in normalizePath(path.expand(path), winslash, mustWork) : path[1]="www\file88b844f719a9.Rmd": The system cannot find the file specified Warning: Error in abs_path: The file 'www\file88b844f719a9.Rmd' does not exist. 1: runApp Session EndedI don't know if it has to do with the code outside the UI that creates temporary files, but that code worked fine before. Here is the code for the app.