nx10 / httpgd

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

Connect remotely (bind to 0.0.0.0) #21

Closed jeroen closed 4 years ago

jeroen commented 4 years ago

I would like to SSH into my remote machine, and see plots locally in my browser. However if I bind to the default 127.0.0.1 then we cannot connect from outside.

So instead on the remote machine, I start with:

httpgd::httpgd('0.0.0.0')
# httpgd live server running at:
#   http://0.0.0.0:33095/live?token=WNoy3Nsn

My local browser can connect to the remote http server (if I replace 0.0.0.0 with my hostname) however the html/js client page doesn't work because javascript is trying to connect to 0.0.0.0.

Screen Shot 2020-06-23 at 12 11 07 AM

I also tried starting the server with httpgd::httpgd('actual.hostname.com') but then I couldn't even connect to the http server remotely.

renkun-ken commented 4 years ago

I remember I tried this a while ago and it worked (or I don't remember correctly?). I just tried again with a remote server listening 0.0.0.0 and it does not work but listening its real intranet IP works (I connect to the intranet from outside via sshuttle).

jeroen commented 4 years ago

Yes using the host ip address seems to work. But it would be nice if it would work with 0.0.0.0 as well.

You probably need to change the html/js client to use the same server address for polling as in window.location because the real intranet IP is often different when the server is behind a proxy.

renkun-ken commented 4 years ago

Yes, definitely.

nx10 commented 4 years ago

Thank you for opening the issue. I just pushed changes that should solve this (0d931080391e8d2d6153e35e9e7c73ffd02ddc36). The html/js client will now access the address to which the GET /live request was sent.

jeroen commented 4 years ago

Hmm it's not working for me. The server is just giving me 401's with "Unauthorized." and the client seems to be assuming json

Screen Shot 2020-06-23 at 1 34 27 AM
nx10 commented 4 years ago

Last commit broke the security tokens. Should work now aaf803f67bf4b47fee1b203daf4b5cc5e97fe201

renkun-ken commented 4 years ago

It works for me now. Thanks!