Working without iframe

Hi!

Is it possible to add opportunity that allows shiny app working as “native” app, i mean without iframe surroundings?

2 Likes

Hi @Alexey_Kuzmrnkov,

There is an option to hide the navbar using hide-navbar: true.
See https://www.shinyproxy.io/configuration/#general

This is typically used when Shiny apps are integrated within larger applications.

Hope this helps.

Best,
Tobias

Thank you, Tobias!

I know about this cool option. But problem is when i use shinyproxy, some js code doesn work (f.e. pseudofull screen on leaflet map in shiny app). And hide navbar doesn t solve this problem. Shiny proxy “paste” my app in iframe object. Is it possible to run shiny app without iframe around it?

Alexey

Hi @Alexey_Kuzmrnkov,

There are two issues that prevent the usage of the shiny app outside of an iframe:

  1. The url is generated dynamically, it cannot be determined beforehand
  2. There is a javascript running alongside the iframe that sends heartbeats to the server, to prevent the app from greying out.

I believe some modifications could allow usage of the app without iframe. Possibly via the addition of some RESTful calls to allocate/release apps.

Alternatively, there is an (experimental) workaround you could try:

  1. Retrieve the html from the url /app/yourappname and parse the generated iframe url from it
  2. Set heartbeat-timeout very high in application.yml, because the heartbeat script won’t be running

Regards,
Frederick

1 Like

If you’re interested, I found a solution based on @fmichielssen suggestions:

  1. Modify the app.html file
  • Replace the iframe tag with <div id="shinyframe" th:src="${container}"></div>
  • Replace $("#shinyframe").attr("src", containerPath); with window.location.replace(location.origin + containerPath);
    That allows you to redirect your page to your shiny app
  1. Add this code your shiny ui file
tags$script('function heartbeat() {
			setTimeout(function() {
				$.ajax("/heartbeat/app/01_hello").success(function(data) {
					heartbeat();
				});
			}, 10000);
		};
		heartbeat();')

That’s it!

3 Likes

@KZARCA @Alexey_Kuzmrnkov: a new heartbeat mechanism (that no longer requires the use of an iframe) has been implemented in ShinyProxy 2.0.0. Also, there is now an API that allows to programmatically manage proxies (no more iframe needed either); see https://www.shinyproxy.io/configuration/#proxy-api

1 Like

Great! Can’t wait to test the new features!

Hi,
I couldn’t find the documentation about the new heartbeat mechanism. Where can I find it?
Best.

Hi @KZARCA, the documentation on heartbeat-rate and heartbeat-timeout at https://www.shinyproxy.io/configuration/#general is unchanged and still applicable.

The internal mechanism uses the standard websocket ping/pong mechanism now. See https://datatracker.ietf.org/doc/rfc6455 section 5.5.2 for more information.

Hope this helps!

Best,
Tobias

1 Like