Disconnected from the server - shinyapps.io & googlesheet

Hi,

I want to run shiny app on shinyapps.io; My app is running almost without problem (
this is app link ), except "add your comment" section. when I run this app locally I can add comment, though when I run it from shnyapp.io and add new comment I get error: "Disconnected from the server".
this comments should save on googlesheets;

what is problem and how to solve it?
thanks

My guess is that your problem is with the way you are providing credential for googlesheets4 but it is impossible to be sure without seen any code.

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at these resources, to see how to create one for a shiny app

thank you @andresrcs for answering. Here is my code:

table <- "responses"
SHEET_ID <- c('1E7JX1_oU0--FXk0FfV0ZrBT38_MJoqvnMI4w3G-ZUxQ')

saveData <- function(data) {
    # The data must be a dataframe rather than a named vector
    data <- data %>% as.list() %>% data.frame()
    # Add the data as a new row
    sheet_append(SHEET_ID, data)
}

loadData <- function() {
    
    # Read the data
    read_sheet(SHEET_ID)
}
fields <- c("name", "comments", "portfolio")
gs4_deauth()

library(shiny)

ui <- fluidPage(
        tabsetPanel(
        tabPanel(
            h3("Reserve Analysis"),
            fluidRow(
                column(4,
                       h5("Add your comment"),
                       textInput("name", "Name"),
                       selectInput("portfolio", "Portfolio", unique(df_long$Portfolio)),
                       textAreaInput("comments", "Add your comment", row = 5),
                       actionButton("submit", "Submit")
                ),
     #there are some other code, but they work without problem          
... 
server <- function(input, output, session) {
      # It is only problematic code
    formData <- reactive({
        data <- sapply(fields, function(x) input[[x]])
        data
    })
       observeEvent(input$submit, {
        saveData(formData())
    })
    output$responses <- DT::renderDataTable({
        input$submit
        loadData()
    })

shinyApp(ui = ui, server = server)

here is picture of problem:

thanks in advance!

If that is your complete code you have forgot to load the googlesheets4 library, you might have done it interactively in your local session and that is why it works locally. As I said before, I'm just guessing since you are still not providing a reproducible example.

To have a better picture of your problem, Could you check what your app's logs say?

1 Like

Thanks, I have solved this issue already.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.