Can Apache Proxy Websockets for Rstudio's Shiny? Can Apache Proxy Websockets for Rstudio's Shiny? apache apache

Can Apache Proxy Websockets for Rstudio's Shiny?


Most likely your R file is handeling Websockets badly.

In your HTML file in your java script, you have something like:

var socket = new WebSocket("wss://"+hostlocation, "HelloR")

And then the following functions which you define as you need:

socket.onopen = function() {}socket.onmessage = function got_packet(msg) {}socket.onclose = function(){}

And in your R code you have something something like:

w = create_server(webpage=static_text_service(htmldata))f = function(DATA,WS,...){list(msg,p)= process(data)websocket_broadcast(toJSON(list(msg=msg, fig=p)),WS$server)}set_callback("receive",f,w)ctmp = tempfile()itmp = tempfile()daemonize(w)

Where htmldata is your html file.

Then modify the httpd.conf to have:

<VirtualHost *:origin_port>  ProxyPass /shiny/  ws://127.0.0.1:3838/  ProxyPassReverse /shiny/  ws://127.0.0.1:3838/</VirtualHost>

where origin_port is the port number of origin and ws://127.0.0.1:3838/ is the address and port of the host.

Make sure you are not missing any of these critical parts. Hope it helps.