On Tue, Feb 5, 2013 at 12:32 AM, Joe Cheng <
j...@rstudio.com> wrote:
> shiny.js uses a raw WebSocket by default, but the mechanism is extensible
> and Shiny Server extends it to use SockJS. Look at the HTML source of e.g.
>
http://glimmer.rstudio.com/jcheng/diamonds/ and do a Find for SockJS and
> you'll see how it's done.
>
> I'm sure you will be able to proxy with nginx, other people (including me)
> have done it with Apache which also doesn't support proxying of ws and it
> works fine.
OHH now I see, the shiny-server invokes apps with the SockJSAdapter.R
wrapper, which injects some HTML/JS snippets. Is there a reason it's
done that way? (Rather than the more obvious thing of having the
framework return the full HTTP response and the Node.js server be a
dumb proxy).
I've written a similar server for R web apps. What I did was just
have R open named pipes for request and response, sort of like CGI,
except the process persists across requests. (Named pipes since the R
interpreter sometimes likes to spew stuff on stdout that you don't
intend.)
That way you can just use a vanilla R interpreter and you don't need
any special C extensions. I just use netstrings to delimit requests
and responses. Then the server, which is in Python, just reads from
those named pipes, and turns it into HTTP, like a CGI server would.
But what I was missing is the JavaScript/Bootstrap part, and I think
you've done a great job on that. People were writing CGI-style R web
apps which can be tedious.
Anyway I'm sort of curious why the R process isn't just a plain HTTP
server rather than a Web Sockets server... I think the only advantage
of web sockets is doing server push? It doesn't appear Shiny uses
that as all updates are in response to a user action. On the other
side, I guess if you changed it to use pipes then people couldn't
develop without running a server as the parent of the R process.
Anyway I think we are about to become a paying RStudio customer from
what I understand (or are already), but I am not sure we could use a
Node.js server in our environment as it's quite specialized sys-admin
wise.
Andy