Getting "Disconnected from the Server" constantly

shiny-server

#1

My app constantly says “Disconnected to the server”, and clicking Reload takes about 1-2 seconds and it is disconnected again. I am loading data via APIs to generate plots. When I run it locally, it takes about 10-15 seconds to get the data and show the charts. Is there some limit to what I can load?

I deployed my app; it appeared normal with one warning that I believe is unimportant:

deployApp()
Preparing to deploy application…DONE
Uploading bundle for application: 257420…Detecting system locale … en_US
DONE
Deploying bundle: 1178904 for application: 257420 …
Waiting for task: 504731250
building: Parsing manifest
building: Building image: 1180987
building: Fetching packages
building: Building package: pack
building: Installing packages
building: Installing files
building: Pushing image: 1180987
deploying: Starting instances
rollforward: Activating new instances
success: Stopping old instances
Application successfully deployed to https://eaf-llc.shinyapps.io/market_data/
Warning message:
In FUN(X[[i]], …) :
Failed to infer source for package ‘pack’; using latest available version on CRAN instead


#2

I have been trying to debug this. The error seems to be related to either (a) reading the .csv file which contains all the strings needed to retrieve data from Yahoo Finance, or (b) the use of those strings in fromJSON or something in that process. I have tried setting encoding, but for some reason that generates an error (even though fromJSON documentation says I can); added it to the read.csv with no effect (found it only accepts latin1 when reading the file from disk).

Added this code based on an article regarding the same error I get:

Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
Sys.setlocale("LC_ALL", "English")

with no effect… The error looks like this:

2018-01-24T18:31:48.502578+00:00 shinyapps[260645]: Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, numerals = numerals,  :

2018-01-24T18:31:48.502588+00:00 shinyapps[260645]:   invalid multibyte string at '<a0>CLH18'

2018-01-24T18:31:52.944298+00:00 shinyapps[260645]:     53: type.convert

2018-01-24T18:31:52.750004+00:00 shinyapps[260645]: No encoding supplied: defaulting to UTF-8.

2018-01-24T18:31:52.919987+00:00 shinyapps[260645]: Warning: Error in type.convert: invalid multibyte string at '<a0>CLH18'

2018-01-24T18:31:52.944295+00:00 shinyapps[260645]: Stack trace (innermost first):

2018-01-24T18:31:52.944298+00:00 shinyapps[260645]:     52: read.table

2018-01-24T18:31:52.944299+00:00 shinyapps[260645]:     51: read.csv

2018-01-24T18:31:52.944300+00:00 shinyapps[260645]:     50: oil_prices [/srv/connect/apps/Market_Data/app.R#153]

2018-01-24T18:31:52.944300+00:00 shinyapps[260645]:     49: server [/srv/connect/apps/Market_Data/app.R#289]

2018-01-24T18:31:52.944301+00:00 shinyapps[260645]:     13

Any ideas would be very much appreciated. BTW it runs locally.


#3

I was able to fix this. The problem appears to have been the need to explicitly specify the encoding in the fromJSON and read.csv commands. I had made the change and redeployed using replace and apparently that wasn’t doing what I thought; deleting the instance and deploying fresh with the changes worked.