Shiny app disconnected from the server. No errors - r

I am running a Shiny app on Ubuntu using the free Shiny server.
When I view the app in a tab in a browser (on MacOS or iPhone) it works fine. If I leave the tab open for a few minutes and return to the tab, I see the familiar translucent grey overlay with a rectangular box in the lower left stating, "Disconnected from the server. Reload".
There are no error indicated at /var/log/shiny-server/app-name... or at /var/log/shiny-server.log.
Here's my shiny server config file:
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
# Defines the amount of time (in seconds) an R process with no active connections should remain open.
app_idle_timeout 0;
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
# When a user visits the base URL rather than a particular application,
# an index of the applications available in this directory will be shown.
directory_index on;
}
}
Based on this post, I thought the addition of app_idle_timeout 0; would prevent this from happening. It hasn't.
Running /opt/shiny-server/bin/shiny-server --version results in:
Shiny Server v1.5.14.948
I understand Dean Attali has created, shinydisconnect, as a way to make this message look nicer. However, I am wondering how to prevent this message from appearing at all if no errors have occurred.

The "Disconnected from Server" error is a generic message that means that the R session has shut down for some reason. This could happen for a multitude of reasons, ranging from missing objects, to data that takes too long to load, to the use of forbidden packages, to hitting the application timeout settings.
The first thing you should do when encountering this error is check the application log. This can be accessed in the shinyapps.io dashboard, under the Logs tab in the Application view, or by running rsconnect::showLogs() in the RStudio console.
This log will contain information about the startup and running of your application. Any errors encountered along the way will be shown here, comparable to the log created when you run the shiny application locally in your own R process.
It may also help to check the Javascript console in your browser while the application is running, which may show additional errors and messages related to your application. The exact instructions for checking this will vary depending on your browser.
If you see errors related to the data, code, or workspace of the application, you will need to fix them before the application will load properly. Remember that applications deployed to shinyapps.io must be independent and self-contained, so all the data, workspace objects, and other resources that the app needs must be deployed with it, or accessible via the internet.
Even if there is no error in the application log, the problem may still lie within your code. There are many resources available online to assist you in debugging and optimizing your app, including our Debugging Shiny Applications article, and the shinyapps-users Google group.
Be aware that your app may run well locally, but fail on shinyapps.io once it comes under load from multiple users. This could happen for a variety of reasons, including but not limited to:
Forgetting to close each database connection after loading in data
Making multiple long-running calls to a public API
Sub-optimal application instance or worker provisioning
Finally, our Scaling and Tuning article describes best practices regarding optimizing the performance of your shinyapps.io application.

Related

R shiny downloadHandler returns a network error after a short duration

The issue I'm encountering has been discussed here on GitHub. The problem I'm having is that, after a short period of time (~45-90sec), the downloadHandler returns a network error instead of the plot.png that is expected. Sometimes the download link will work but it's hit or miss. The shiny app is deployed on an Open onDemand HPC setup. From the shared discussion, the advice is to add http_keepalive_timeout 600; to the shiny-server.conf file. My problem is that I'm not aware of any shiny-server.conf file. The shiny-server docs says the file is located at /etc/shiny-server/shiny-server. conf. Can anyone tell me how to find this file? I have very little experience with app deployment and the engineer who deployed the app for me is not aware of any such file/location.

Shinyapps.io on safari browser cannot connect to server "localhost "

I've created a basic app in shiny that connects and uploads data to a shared googlesheet. The app works fine locally, however when I try to run it in a web browser, it won't upload any data.
The problem seems pretty straight forward. Using shiny apps.io I can view the apps logs, and it identifies that I need to provide the app permission, (specifically shinyapps and tidyverse) to upload data to google sheets, which is authorized by google sheets. This is no problem as I went through the same process on my own machine locally:
1) I'm running on a Mac, OSX Mojave v 10.14.2
2) I've enabled web sharing via the terminal with sudo apachectl start (I think that's all it took?)
3) I've scoured similar problems on here.
4) The app opens and uploads data when I "view in browser" from the RStudio IDE
5) I wanted to try Shiny Server, however apparently they haven't written anything for Macs yet that doesn't have to built from source, which is way beyond my level.
6) The google sheet is published to the web as well.
This is the provided message from shinyapps.io logs
Listening on http://127.0.0.1:37073
2019-01-15T14:33:32.976569+00:00 shinyapps[636194]: Adding .httr-oauth to .gitignore
2019-01-15T14:33:33.012405+00:00 shinyapps[636194]: Please point your browser to the following url:
2019-01-15T14:33:33.010168+00:00 shinyapps[636194]: Waiting for authentication in browser...
2019-01-15T14:33:33.010485+00:00 shinyapps[636194]: Press Esc/Ctrl + C to abort
2019-01-15T14:33:33.012759+00:00 shinyapps[636194]: "This is the provided URL"
I then go to the provided URL, that takes me to a accounts.google page that asks me to provide authentication to a specific google account, which I do.
I then receive this error from safari:
Safari can't open the page "the provided URL" because safari cannot connect to the server "localhost"
I would basically like this app to be used only by the allowed google account which is a shared one and be able to upload from at most 3 different machines that are windows, Any help appreciated!
I've found a temporary work around, in my code since I take advantage of the google sheets package in R, it as a function called:
gs_title("worksheet title")
this allows the app to identify the worksheet that has been given access to the app, however this is a problem when uploading the app online, I used a different function called:
gs_url("worksheet URL as copied from search bar")
It passes the url of the worksheet apparently bypassing the local server problem, and allowing me to open the app from other machines.

Using IIS Express for Local Web Application with Multiple Users [duplicate]

I have a line of code that I can run locally as part of a service that works perfectly fine.
sReportPath = objCrystalUtils.ExportReportToPDF("Report Name", iReportInfoID)
This code is run as a part of a service, and when I unit test it by feeding it data, it ultimately builds the report and prints it.
When I run the exact same piece of code inside an .ashx from an ajax call. The reports are generated (I can see the pdf files being created on disk) but the printing is not happening.
oRpt.PrintToPrinter(objReport.DefaultAutoPrint, True, 0, 0)
In both scenarios the same code is used to print the report. (objReport.DefaultAutoPrint = 0 in both cases)
My only thought is that the location of the code that is calling this method is in a different spot relative to the location of the bills themselves.
The printer that I'm trying to print to is a network printer intalled on my machine, and I'm running Windows 7 IIS 6.1
Any thoughts?
Edit:
Here is a thought... if I'm running one as a unit test locally and im running the other through a web app that is running via IIS, is there a difference in user id and user access to the default printer?
Edit:
So I added my local ASP, IUSR and SYSTEM users to the printer security and allowed them to print... no dice. So I checked the EVERYONE user and it is set to access and NO users are denied... so I think that kinda kills that line of reasoning.
Edit:
I changed the name of this post since I no longer think that the issue is ajax related since If I try to do the same process in code bebehind from a post back instead of running it from an ajax call i still get the same problem.
Patrick, for me it is a known issue of crystal reports, printing a certain report from a running application via IIS.
I got the same issue before, and upon our search for that issue, we got the following;
Report to be generated, exported, and then to be downloaded to client machine,
so user can print it locally (say, report will be exported as PDf file,
user can use print option of PDF reader).
It's not Crystal Reports or other third party app's problem. It's usually the IIS_IUSER's permission problem because it has no access to any network printers. A possible solution is in Process.Start doesn't work in IIS

RadEditor ExportToPDF not generating PDF in client's environment

We are using the Telerik RadEditor control, specifically for it's ability to render a PDF via the ExportToPDF() method on the control. We find that this works great in our development and test environments but fails as soon as we get to our client's environment. What I mean by fails is that typically when you execute the ExportToPDF() method, a dialog box pops up with the name of the PDF file, it's size, and whether you want to open it or save it. In our client's environment that dialog window appears, but the file size does not appear. If you save the file, it's a blank document. The machines / environments are equal in their setup (IIS 6 on Windows server 2003). The only exception is that our client's machine is in a secure environment with no access to the internet.
We are loading form letters into the control and then creating the PDF once the user clicks a button, so I don't think this is being caused by bad data / invalid characters causing the PDF not to generate.
My questions are: does anyone have experience running the ExportToPDF() command in an environment with no access to the internet? Could this be a permissions issue? I can't seem to find documentation on whether the ExportToPDF() functionality uses a temporary directory to write the PDF out to while it's rendering. It may be as simple as that, but I'm having a hard time researching this issue.
I've also put a try / catch block around the ExportToPDF() method and I know it's not throwing any errors.
We are running an older version of RadEditor - 2009.3.1208 - it runs in a large application with other Telerik tools so upgrading the entire RadControl suite is not trivial (b/c of testing, etc) and is taking some time.
Any suggestions on what to try next / has anyone encountered anything like this with this control?
Thanks for your help in advance!
Richard
I doubt that the export functionality needs an active internet connection. Most likely something in your secured environment is blocking silently the export and it does not simply happen. My recommendation is to check the permissions/processes you have on the user machine and test the same outside of the local environment to compare the results.

ASP.NET MVC - Unable to print ASP.NET Charting control on server

Trying to print an ASP.NET Charting control behind the scenes in my web app. I think it is a permissions issue with the printer as everything is ok up until the point where my code calls:
chart.Printing.Print(false);
bool finished = false;
while (!finished)
{
finished = File.Exists(settings.GetValue("statusfile")); // file which indicates document was printed
System.Threading.Thread.Sleep(1000);
}
At this point the page just freezes (or continues to load endlessly - infinite loop!) Understandably this is happening because I am 100% relying on the document being printed. I do intend to add a timeout, however, at the moment I am just trying to figure out why exactly the document is never being set to the printer!
I have given the account (which the AppPool is running under) permissions to all the relevant folders and even the pdf printer itself...Still nothing.
Am I missing something? Is there any issues with printing on the server side via ASP.NET? I have encountered some issues doing this via WindowsServices in the past not sure if it is a similar problem with ASP.NET websites.
Update
As suggested I updated the AppPool to give myself (admin) permissions and it is the same issue. So by the looks of things the job is never being sent to the printer. I can't seem to figure out why though...
Probably should have mentioned this in my original post....but I am invoking the printer through a referenced DLL, this code is not being called directly from my application (incase it matters). Also this runs fine on my Development machine which is running Windows 7 IIS7.0 where as the server is running Windows 2003 server with IIS6.0.
Update 2
I removed the while loop and just left in the chart.Printing.Print(false) line and turns out the document IS being sent to the printer. So the issue must be with the settings file not getting written which is why the loop never breaks out!
To isolate if this is indeed a permissions issue, you could try running the application using the Visual Studio web development server, which will run under your credentials. Or if that's not an option, temporarily change the IIS app pool so it uses your credentials. If things still do not work, you may have another issue. I'm not sure which charting library you're using (is it the newish Microsoft one?), but maybe Print wants to show a printer dialog.

Resources