8

I'm trying to upload a shiny app on Shiny.io. The app gets deployed and when the link is tried the app gets crashed by throwing an error Disconnected from Server. When I checked in the Logs of the dashboard, it says Error in the server: could not find function "server".

I was not able to find the solution for this. Documents and articles regarding the same shows that the Packages used could be one of the reasons for the error but I'm not able to find the list of packages that will be compatible or not.

These are the list of packages/libraries that are used in my app,

  1. Shiny
  2. Earth
  3. ggplot2
  4. Plot3D
  5. visreg
  6. rgl
  7. zoo
  8. Hmisc
  9. dplyr
  10. shinyBS
  11. shinycssloaders

Thanks in Advance!!

UPDATE

Below are the reproducible ui.R and server.R scripts. Upon debugging I found that this part of the code is error while deploying.

ui.R

library(shiny)
library(shinyBS)
library(shinycssloaders)
options(shiny.trace=TRUE)

shinyUI(pageWithSidebar(



  fluidRow(
   column(width = 4,height = 4,img(src='image.png', align = "left", height = 
   50, width = 200)),
   column(8,titlePanel("Analysis"))
 ),


  sidebarPanel(

  br(),

  fileInput("file1", label = ("  Data "),multiple = F),

  fluidRow(
    column(12,align ="center", actionButton("button", "Analyze",style = 
    "background-color : skyblue", icon = icon("stats", lib = 
     "glyphicon"),width = 250 )))


 ),
 mainPanel(

   bsAlert("alert"),

   br(),

    fluidRow(        

     tabsetPanel(
      tabPanel("Table",icon = 
       icon("table"),withSpinner(dataTableOutput('table'), type = 
       getOption("spinner.type", default = 8) ))

      )
     )
   )
 ))

server.R

  library(shiny)
   library(shiny)
   library(earth)
  library(ggplot2)
   library(plot3D)
  library(visreg)
  library(rgl)
  library(zoo)
  library(Hmisc)
  library(dplyr)
  library(gridExtra)

  options(shiny.maxRequestSize=30*1024^2) 
  options(shiny.trace=TRUE)

  if (interactive()){
    shinyServer(function(input, output,session) {
    dataframe <- reactive( {

    ###  Create a data frame reading data file to be used by other 
    functions..
      inFile <- input$file1     
      data1 <- read.csv(inFile$datapath, header = TRUE)


     })

     table1<- eventReactive(input$button, dataframe())
      output$table <- renderDataTable({table1()})

    })
 }

Thanks!

Tareva
  • 230
  • 1
  • 13
  • Could you please share your code also? – amrrs Oct 31 '17 at 06:35
  • @amrrs Thanks for the response. Well, I have around 800 Lines of code which is not recommended to post, so that was the reason I didn't post it. Is it that Code is required to give solutions? – Tareva Oct 31 '17 at 06:42
  • 1
    There is a concept of reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example . Considering your error, it seems you've used `server` object in your code which isn't present. – amrrs Oct 31 '17 at 06:43
  • @amrrs Yes, In my code there is a *shinyServer()* function but isn' t that must required function where all my other server scripts goes in. And Thanks for the link, I will try to post reproducible script. – Tareva Oct 31 '17 at 06:55
  • @amrrs I'm Sorry for the delay, I have updated the post with reproducible scripts. – Tareva Nov 06 '17 at 05:41
  • Does the code execute fine in your location machine? If yes, how did you run the code? – amrrs Nov 06 '17 at 06:42
  • Yes! Code executes fine in my local machine. I ll run it through RStudio IDE. – Tareva Nov 06 '17 at 06:51

1 Answers1

2

Finally I was able to debug the code and find a solution for the error.

From Server.R delete the statement if (interactive()) and delete session parameter from the shinyServer(function(input,output,session)).

Hence deployed without any error.

Replace the following server.R script and it should work fine.

 library(shiny)
 library(shiny)
 library(earth)
 library(ggplot2)
 library(plot3D)
 library(visreg)
 library(rgl)
  library(zoo)
 library(Hmisc)
library(dplyr)
library(gridExtra)

options(shiny.maxRequestSize=30*1024^2) 
 options(shiny.trace=TRUE)

shinyServer(function(input, output) {
dataframe <- reactive( {

  ###  Create a data frame reading data file to be used by other functions..
  inFile <- input$file1


  data1 <- read.csv(inFile$datapath, header = TRUE)


   })

   table1<- eventReactive(input$button, dataframe())
   output$table <- renderDataTable({table1()})

  })
Tareva
  • 230
  • 1
  • 13