nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
390 stars 19 forks source link

Http server disconnected #3

Closed renkun-ken closed 4 years ago

renkun-ken commented 4 years ago

I'm testing on a Ubuntu 18.04 Server in local network.

httpgd::httpgd(host = "0.0.0.0", port = 24680)

When I open the URL http://localserver:24680, it shows httpgd server running. which looks normal. But in http://localserver:24680/live, the page is blank and then shows Disconnected on the top-right corner:

image

Then I run the following code in R:

plot(rnorm(100), main = "title")
abline(h = 0, col = "red")

and the webpage in browser shows the graphics in a couple of seconds.

If I open the page in a webview in VSCode,

getOption("browser")("http://localhost:24680/live")

The graphics is never shown.

I'm not sure if there's something missing but httpgd works nicely via VSCode Remote Development as I tested from my macOS connecting via sshuttle to my work place desktop server.

renkun-ken commented 4 years ago

This is very likely caused by remote (localhost) and local (localhost) port forwarding conflict in WebView in VSCode Remote Development. Let me take a closer look at this.

When I start the http server with the real intranet IP of the server, and open a webview of that IP in the URL, then the web view works.

renkun-ken commented 4 years ago

The port forwarding has no problem. I tried with

httpgd::httpgd(host = "127.0.0.1")

and everthing works fine.

I guess we should use 127.0.0.1 as the default host instead of localhost as shiny, R help http server both uses 127.0.0.1 host by default.