Port numbers keep changing for Shiny Server in RHEL 6.5

737 views
Skip to first unread message

jeem0...@gmail.com

unread,
Mar 14, 2016, 10:14:49 PM3/14/16
to Shiny - Web Framework for R
Hi,

Currently setup my shiny server but faced an issue with firewall and port numbers.  As we are securing the server, the firewall only allow 3838, somehow every new session of the application will obtain a random port number, example is below where it tries to obtain a connection to port 40876. Its completely random port every time I restart my shiny server. Is there anyway to fix a port or a few ports? 

Example I tried to access my application http://192.168.1.1:3838/myShinyApp/ and the below error appear. I have to totally disable my server firewall to make it work.

An error has occurred

The application failed to start.

The application took too long to respond.

jeem0...@gmail.com

unread,
May 6, 2016, 6:02:53 AM5/6/16
to Shiny - Web Framework for R
Nobody face this kind of problem? Surely you cant let shiny-server be run on any port number it choose.

Tareef Kawaf

unread,
May 6, 2016, 9:38:00 AM5/6/16
to Shiny - Web Framework for R
Shiny server is configurable to run on a given port and shouldn't be using other ports.  Do you have a reproducible example that you could share that illustrates the problem?

jeem0...@gmail.com

unread,
May 8, 2016, 10:04:16 PM5/8/16
to Shiny - Web Framework for R
Hi, a very good example is the default startup page 'index.html' where it shows the shiny server is up. On the right pane, the 2 default application will have the problem below. And both will show different port numbers.

Is there a way to use a specific port? I am using server.R and ui.R for my application
 
 

An error has occurred

The application failed to start.

The application took too long to respond.

Listening on http://127.0.0.1:<port number> 

jeem0...@gmail.com

unread,
May 8, 2016, 10:50:54 PM5/8/16
to Shiny - Web Framework for R
I have to disable iptables for the application to work. '/etc/init.d/iptables stop'

As the server will be deployed to a classified location, we cannot allow the shiny server to have no basic firewall rules in place


Tareef Kawaf

unread,
May 9, 2016, 8:49:25 AM5/9/16
to Shiny - Web Framework for R
Can you tell us which version of shiny server you are running with and whether this is a plain install of RHEL 6.5?  I would like for us to see if we can reproduce the issue, this is definitely not something I have heard before.

jeem0...@gmail.com

unread,
May 9, 2016, 11:13:27 PM5/9/16
to Shiny - Web Framework for R
Hi Tareef, thanks for the reply.

Overall I am only using a server.R and ui.R to run my app. If you restrict the linux server to only allow 3838 for shiny-server, should face the same problem as i have.

1.Shiny Server rpm is 1.4.1.759 64Bit. So i assume this is the version.
2. R version is using 3.2.1
3. Linux version is RHEL 6.5. Just plain installation.

4. For /etc/sysconfig/iptables
-A OUTPUT -p tcp --sport 8787 -m state --state ESTABLISHED -j ACCEPT (this is for r studio)
-A OUTPUT -p tcp --sport 3838 -m state --state ESTABLISHED -j ACCEPT ( this is the shiny server default port)

5. Rstudio version is not important as we are not using it to run shiny app

6. In the /etc/shiny-server/shiny-server.conf, the server is listening on port 3838

Ian Pylvainen

unread,
May 10, 2016, 12:26:32 AM5/10/16
to jeem0...@gmail.com, Shiny - Web Framework for R
Hi,

We're not able to reproduce this error on our end. Can you try installing the latest version of Shiny Server (see here: https://www.rstudio.com/products/shiny/download-server/) and let us know if you're seeing the same issue there?

Thanks,
Ian

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/7c36ba27-d7ab-400f-b805-7387358f03b3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

jeem0...@gmail.com

unread,
May 10, 2016, 1:57:29 AM5/10/16
to Shiny - Web Framework for R, jeem0...@gmail.com
Iptables of Linux  set to this and the shiny app can still work?

/etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Mon May  9 10:57:12 2016
*filter
:INPUT ACCEPT [443663:43792218]
:FORWARD ACCEPT [0:0]
:OUTPUT DROP [2438:146908]
-A OUTPUT -p tcp -m tcp --dport 1521 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 8787 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p udp -m udp --sport 123 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 3838 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT
COMMIT

jeem0...@gmail.com

unread,
May 12, 2016, 3:30:20 AM5/12/16
to Shiny - Web Framework for R
Resolved. Need to add the 2 lines to your iptables in order for the internall firewall not to block traffic for 127.0.0.1  
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT


Explanation is by Joe Cheng below
 
Port 3838 is the (default) port that Shiny Server listens on. Shiny Server then launches multiple R processes to run the actual Shiny apps; these also need ports to listen on, and they can't be 3838 as it is taken by Shiny Server. So they listen on random ports chosen by Shiny Server. However, these ports can only be accessed from localhost, and furthermore a "shared secret" is passed from Shiny Server to each Shiny process so that no other processes can perform requests against those random ports.

Please configure your firewall not to block ports on 127.0.0.1, and it should work.
Reply all
Reply to author
Forward
0 new messages