web server only working for localhost

207 views
Skip to first unread message

Harlan Harris

unread,
Jun 27, 2011, 6:13:06 PM6/27/11
to rRook
Hi, this is probably marginally off-topic, but maybe not. I'm trying
to set up a web status page for an R application that runs
continuously, using Rook. The code to start the web server is as
follows:

ws <- Rhttpd$new()
ws$add(RhttpdApp$new(name='AppStatus', app=AppStatus))
ws$start(port=app.port, quiet=TRUE)

Where AppStatus is a function and app.port is a scalar (9898). I can
connect to the server on the local host, as follows (this is on a
Linux box):

curl http://localhost:9898/custom/AppStatus

That works fine. But when I use the IP address of my machine, ala:

curl http://123.123.123.123:9898/custom/AppStatus

I get this error: curl: (7) couldn't connect to host

Likewise, I can't connect to the app from an external machine. Other
(non-R) web servers run fine. This is not affected by whether or not
I'm running the firewall (iptables).

What could be preventing the R web server from receiving connections?
It's not limited to connections to/from localhost, is it?

Thanks!

-Harlan


Jeffrey Horner

unread,
Jun 27, 2011, 6:54:02 PM6/27/11
to rr...@googlegroups.com
Indeed, you should be able to use another ip address. Just set the
listen argument to the start method like so:

ws$start(listen='123.123.123.123',...)

You may even be able to use listen='*' to listen on all interfaces but
I'm unsure of this.

Jeff

Harlan Harris

unread,
Jun 28, 2011, 9:57:02 AM6/28/11
to rRook
Aha, thanks! For me, it seems as if the IP address of the server is
required. * doesn't appear to work.

It would be great if there were an example in the help files of using
the listen argument. It's documented, but only if you know what you're
looking for. Which I wasn't. :)

Thanks! This is a great new project!

-Harlan

On Jun 27, 6:54 pm, Jeffrey Horner <jeffrey.hor...@gmail.com> wrote:
> Indeed, you should be able to use another ip address. Just set the
> listen argument to the start method like so:
>
> ws$start(listen='123.123.123.123',...)
>
> You may even be able to use listen='*' to listen on all interfaces but
> I'm unsure of this.
>
> Jeff
>
>
>
>
>
>
>
> On Mon, Jun 27, 2011 at 5:13 PM, Harlan Harris <harlan.har...@gmail.com> wrote:
> > Hi, this is probably marginally off-topic, but maybe not. I'm trying
> > to set up a web status page for an R application that runs
> > continuously, using Rook. The code to start the web server is as
> > follows:
>
> > ws <- Rhttpd$new()
> > ws$add(RhttpdApp$new(name='AppStatus', app=AppStatus))
> > ws$start(port=app.port, quiet=TRUE)
>
> > Where AppStatus is a function and app.port is a scalar (9898). I can
> > connect to the server on the local host, as follows (this is on a
> > Linux box):
>
> > curlhttp://localhost:9898/custom/AppStatus
>
> > That works fine. But when I use the IP address of my machine, ala:
>
> > curlhttp://123.123.123.123:9898/custom/AppStatus

Trannon

unread,
Jul 7, 2011, 2:46:53 PM7/7/11
to rRook
Hi Jeff,

I am having a similar issue as Harlan, but when I try to use the
'listen' argument it has no effect. Rook seems to be starting the
server with the 'new()' command. For example, when I execute:

library(Rook)
s <- Rhttpd$new()
s$print()

It returns:

Server started on 127.0.0.1:10347
No applications installed

Then, when I try to use 's$start(listen='123.123.123.123', port=1234,
quiet=FALSE)', I get the following warning:

Warning message:
In s$start(listen='123.123.123.123', port=1234, quiet=FALSE) :
RStudio has already started the web server on port 10347

and I cannot seem to edit the IP or port. Any ideas/suggestions would
be greatly appreciated.

Thanks,
Trannon

P.S. I am using RStudio as my IDE - not sure if that is the culprit.
However, I have had no luck using the Rgui either.


On Jun 27, 3:54 pm, Jeffrey Horner <jeffrey.hor...@gmail.com> wrote:
> Indeed, you should be able to use another ip address. Just set the
> listen argument to the start method like so:
>
> ws$start(listen='123.123.123.123',...)
>
> You may even be able to use listen='*' to listen on all interfaces but
> I'm unsure of this.
>
> Jeff
>
> On Mon, Jun 27, 2011 at 5:13 PM, Harlan Harris <harlan.har...@gmail.com> wrote:
> > Hi, this is probably marginally off-topic, but maybe not. I'm trying
> > to set up a web status page for an R application that runs
> > continuously, using Rook. The code to start the web server is as
> > follows:
>
> > ws <- Rhttpd$new()
> > ws$add(RhttpdApp$new(name='AppStatus', app=AppStatus))
> > ws$start(port=app.port, quiet=TRUE)
>
> > Where AppStatus is a function and app.port is a scalar (9898). I can
> > connect to the server on the local host, as follows (this is on a
> > Linux box):
>
> > curlhttp://localhost:9898/custom/AppStatus
>
> > That works fine. But when I use the IP address of my machine, ala:
>
> > curlhttp://123.123.123.123:9898/custom/AppStatus

Jeffrey Horner

unread,
Jul 7, 2011, 2:57:36 PM7/7/11
to rr...@googlegroups.com
On Thu, Jul 7, 2011 at 1:46 PM, Trannon <tra...@gmail.com> wrote:
> Hi Jeff,
>
> I am having a similar issue as Harlan, but when I try to use the
> 'listen' argument it has no effect.  Rook seems to be starting the
> server with the 'new()' command.  For example, when I execute:
>
> library(Rook)
> s <- Rhttpd$new()
> s$print()
>
> It returns:
>
> Server started on 127.0.0.1:10347
> No applications installed
>
> Then, when I try to use 's$start(listen='123.123.123.123', port=1234,
> quiet=FALSE)', I get the following warning:
>
> Warning message:
> In s$start(listen='123.123.123.123', port=1234, quiet=FALSE) :
>  RStudio has already started the web server on port 10347

Unfortunately you cannot listen on arbitrary ports and interfaces when
running Rook under RStudio. JJ (RStudio's athor) and I agreed on that
since RStudio manages the internal web server.

>
> and I cannot seem to edit the IP or port.  Any ideas/suggestions would
> be greatly appreciated.
>
> Thanks,
> Trannon
>
> P.S.  I am using RStudio as my IDE - not sure if that is the culprit.
> However, I have had no luck using the Rgui either.

Hmm... I wonder why there would be issues with Rgui. I've never used
it, so that's news to me.

Jeff

Reply all
Reply to author
Forward
0 new messages