daattali / shinydisconnect Goto Github PK
View Code? Open in Web Editor NEW🔌 Show a nice message when a Shiny app disconnects or errors
Home Page: https://daattali.com/shiny/shinydisconnect-demo
License: Other
🔌 Show a nice message when a Shiny app disconnects or errors
Home Page: https://daattali.com/shiny/shinydisconnect-demo
License: Other
Hi There,
First I have to say that this is great work! I really enjoyed this package.
I am making a web app in shiny and I just wonder is it possible to do something like : disconnectMessage(text = HTML(" Raw HTML")).
Right now it will not look at the strong tag and produce some other symbols in the popup window.
I think that this will be very useful for people using this package because they can include a link such as a feedback form once their users encounter a disconnect.
This is not an issue as such, however, I was thinking it would be nice to have separate disconnect functions, one for errors and another one for session timeouts. Right now, if I customize the disconnect message for timeout, it doesn't look meaningful for the users when the app stops because of an error that had occurred and vice versa.
There seems to be an error that prevents application from loading if I insert in UI section.
ui <- dashboardPage(
disconnectMessage2(),
further elements(...),
Then upon loading this happens:
<script>$(function() { $(document).on('shiny:disconnected', function(event) { $('#ss-connect-dialog').show(); $('#ss-overlay').show(); })});</script>
<div id="ss-connect-dialog" style="display: none;">
<a id="ss-reload-link" href="#" onclick="window.location.reload(true);"></a>
</div>
<div id="ss-overlay" style="display: none;"></div>
Error in tagAssert(header, type = "header", class = "main-header") :
Expected an object with class 'shiny.tag'.
And nothing loads. What could this mean? Thanks.
A simple example:
shinydisconnect
example locally on Chrome, you should see a tab opens.or:
You will find the app is back, All UI is clickable. As expected, for those need the backend will not work, but still, users can play around which is not ideal. In the original Shiny, this is prevented by the shiny-disconnected-overlay
. Sine you disabled it #shiny-disconnected-overlay { display: none !important; }
, the protection is gone.
Here is what I did:
#shiny-disconnected-overlay
back but one layer below 99997, so the #ss-connect-dialog
is till on top.ss-connect-dialog
to .shiny-discon::before
and .shiny-discon-noserver
. I toggle the class later in js.disconnetMessage
on the UI side, just like your other examples which are fine, my checker will be deleted after first 3s. In your, demo, you insert this to DOM and immediately stops the sever. So the script is inserted at the same time as the server closes. So my function runs after the sever is ended. So, it will first display your error message but 3s later change to "Cannot connect to the server". To fix this, I fake the socket after shinyapps.js delete it: $(document).on('shiny:disconnected', function(event){
setTimeout(function() {
Shiny.shinyapp.$socket = 'fake';
}, 1000);
});
I tried locally and deployed it to my account with no problem, fixed this issue. Please try it out #5 .
Hi there,
thanks for this great package!
I tried to use your code in app on shiny server open source to route users back to a log in website.
Therefore I adjusted your utils.R, simply trying to add a link.
Strangely, it still only reloads, even if I remove "onclick="window.location.reload(true);" replace with onclick="window.location='https://www....';" or just add a link to href.
Is this somehow hardcoded on the side of shiny server ?
Hi Dean,
I'm trying to run shinydisconnect in 3 Windows computers and, in each one of them, when I click on the "Disconnect the app" action button, each obediently closes the page but no message, box, or little window shows up. The page is just closed and I'm left with the "Listening on http://127.0.0.1:..." standard message. This happens with both disconnectMessage and disconnectMessage2.
The reprex is virtually the same as in the demo (I just added the library(shinydisconnect) statement).
library(shiny)
library(shinydisconnect)
shinyApp(
ui = fluidPage(
disconnectMessage(),
actionButton("disconnect", "Disconnect the app")
),
server = function(input, output, session) {
observeEvent(input$disconnect, {
session$close()
})
}
)
However, everything works well in the demo page: https://daattali.com/shiny/shinydisconnect-demo/
Would you have any suggestion to make it work or, at least, to try to find out what's wrong on my side?
Thanks,
CW
I'm using Chrome Version 98.0.4758.102 (Official Build) (64-bit) in my 3 Windows computers. The RStudio/Shiny/Windows versions are:
Thank you for this package, very useful. Not sure if it's possible, I've been looking all over for this: is it possible to display a message that shows the cause for disconnecting from the Shiny server? Preferably with a stack trace to the error. This will make it easier for users of an app to file a bug report, and for the developer to fix the problem.
The problem is probably that once the app is disconnected, you can’t get any information from the server, apart from what is been send to ‘event.socket’ by ‘shiny:disconnected’ to the client side (javascript). From what I could tell, this socket appears empty after a crash. Maybe you have some fresh ideas?
Thanks in advance!
Hi, when a disconnect occurs (due to fatal error or timeout) I would like to also write at least the time, URL etc to a log. Is there any way to include an additional function, say within disconnectmessage(), eg myFunctionToWriteTheErrorToAFile() ? So that the user would still see the disconnect message but at least some basic information would be written to a file?
The shinydisconnect package is great!
I'm curious about how one might also restyle the "attempting to reconnect" dance that Shiny performs (to salvage the SockJS robust socket) prior to a full disconnection requiring a page reload.
I suppose one could always write a bubbling event listener to swap-out the text in tags with this class ... but perhaps that could be included in the shinydisconnect package, too?
A nice addition to the reload process (though this requires a bit more FE code than the current onclick
handler) would be to allow adding (or overwriting) an existing URL query parameter on the reload.
The main reason for this would be to allow for easier differentiation in logs between pageloads/reloads via initial requests or the browser's buttons and via the shinydisconnect interface itself.
Hypothetical example:
disconnectMessage(
text = "Oops",
refresh = "Click here to reload",
query = list(
"disconnectMessageReload" = 1
)
)
query
would either introduce new URL query string args or update existing ones (i.e. upsert) with the standard URL-encoded key/value pairs.
The server function (or fronting server -- e.g. NGINX -- logs) can then inspect the URL for that key to help track that behavior.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.