Using Shiny in embedded browser in SWT from localhost

209 views
Skip to first unread message

John Dimeo

unread,
Mar 21, 2014, 1:22:52 PM3/21/14
to shiny-...@googlegroups.com
I'm trying to use Shiny in an embedded SWT Browser so I can display (awesome) Shiny apps "natively" in a Java UI.  It works when I use an external URL (for example http://glimmer.rstudio.com/jcheng/diamonds/) but when I try to run one of the examples locally, the HTML on the left pulls up but the plot never shows. Is this because the diamonds example is running Shiny server?  It's important that it works with a localhost URL for how I'm trying to use it.
- Browser doesn't seem to matter. I have a modern version of IE, and I tried FF and JavaFX's webkit, all with the same effect
- I'm not using a proxy
- I tried 127.0.01, localhost, my computer name on the domain, and my IP address

Thanks!

Fereshteh Karimeddini

unread,
Mar 24, 2014, 10:21:45 AM3/24/14
to shiny-...@googlegroups.com
Hi John,

Please provide the following information so we have a clearer picture of what and how you are trying to use your Shiny application.

- When you say locally, do you mean you are running the "runApp()" or "runExample()" command to launch the application? 
- Which of the examples are you running? (I assume you see the same problem with all examples, but just to be sure)
- Which version of Shiny package are you running? (or better to provide output of sessionInfo() command)
- Do you see any errors in the browser console?

Thanks,
Fereshteh

John Dimeo

unread,
Mar 24, 2014, 3:08:51 PM3/24/14
to shiny-...@googlegroups.com
Hello Fereshteh,
Thank you so much for your help. I apologize for not providing more detail up front.
- I mean using runExample(), but I imagine the effect would be the same with runApp()
- I was using 01_hello, but I tested a few others and they all had the same effect
- R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_0.8.0

loaded via a namespace (and not attached):
[1] bitops_1.0-6  caTools_1.16  digest_0.6.3  httpuv_1.2.3  Rcpp_0.11.1  
[6] RJSONIO_1.0-3 xtable_1.7-3 

- There's no way to access the browser console that I know of when you embed it via SWT. I think this is because it's just embeding the rendering engine, not a true first-class browser (I tried hitting F12 with no luck).  One of my ideas was that it wasn't able to find/load CSS and JS files wth relative paths for some reason, but unfortunately I have no way of knowing.  The R console spit out a few "ERROR: [on_request_read] connection reset by peer" errors.
 
Here's the Java code:
public class BrowserTest {
public static void main(String[] args) {
Device.DEBUG = true;
Display d = new Display();
Shell s = new Shell(d);
s.setSize(800, 600);
s.setText("Browser Test");
s.setImage(d.getSystemImage(SWT.ICON_QUESTION));
s.setLayout(new FillLayout(SWT.HORIZONTAL));
new Browser(s, SWT.NONE).setUrl("http://localhost:4492");
new Browser(s, SWT.NONE).setUrl("http://glimmer.rstudio.com/jcheng/diamonds/");
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch()) { d.sleep(); }
}
}

And here's what it looks like when it's run:

Thanks so much for trying to help.
    -John

Fereshteh Karimeddini

unread,
Mar 25, 2014, 12:49:15 PM3/25/14
to shiny-...@googlegroups.com
John,

Thanks for providing this info. Since I myself do not have much experience with SWT, I wanted to get as much information as I could before digging more into it. I will look into this issue and update the post.

Best,
Fereshteh

Mary Ann Bitz

unread,
May 30, 2014, 9:05:17 AM5/30/14
to shiny-...@googlegroups.com

I ran into the exact same problem and found a solution after struggling for several days.  The problem was the firewall here.  When I ran the application as administrator it prompted me to allow the access and after then it worked perfectly.  So the problem is not with SWT browser, but with the permission on your machine. When I ran the application outside of eclipse from a jar, I also had the same issue and resolved it by running as administrator.  Hope this helps anyone who runs into the same issue.
Reply all
Reply to author
Forward
0 new messages