Score:2

How to configure streamlit to serve an app to www?

cn flag

streamlit app is running in a centOS stream 8 virtual machine. Access from intranet is fine but fails with "streamlit please wait.. page" when accessed from www via subDomain.companyDomain.com

Tested R shiny app and a static page from same virtual machine and same port. Both are successfully accessible from www with subDomain.companyDomain.com

network schema network schema

subDomain != virtualMachineName

company proxy server is ssl enabled

streamlit config.toml

[server]
port = 8585
headless = true
enableCORS = false
enableXsrfProtection = false
enableWebsocketCompression = false
address = "0.0.0.0"

[browser]
gatherUsageStats = false
serverAddress = "subDomain.companyDomain.com"

Edit 1:

tested Apache reverse proxy

/etc/httpd/conf.d/testApp.conf

<VirtualHost *:80>
    ServerName subDomain.companyDomain.com
    ServerAlias www.subDomain.companyDomain.com
    ProxyPreserveHost On
    ProxyPass "/" "http://local_IP:8585/"
    ProxyPassReverse "/" "http://local_IP:8585/"
    ErrorLog /var/log/httpd/testApp-error.log
    CustomLog /var/log/httpd/testApp-access.log common
</VirtualHost>

Interestingly, after redirecting http:local_IP:8585 to Apache virtualHost *:80, both local_IP:80 and subDomain.companyDomain.com hang at the same "streamlit.. please wait" page.

(btw, httpd/testApp* log files are empty)

Edit 2

With nginx (this thread), both http://local_IP:8585 and http://local_IP:80 correctly display the app. However, subDomain.companyDomain.com continues to hang with "streamlit please wait" page.

server {
    listen 80;

    location / {
        proxy_pass http://local_IP:8585/;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
    }
}

browser trace suggests error in redirection to/from company proxy server via websocket. But i can not pin point where and how to resolve error.

Edit 3 Tracing browser request via DevTools

enter image description here enter image description here

ss -tulpn |grep "streamlit"
tcp LISTEN 0 128 0.0.0.0:8585 0.0.0.0:* users:(("streamlit",pid=206126,fd=8)) 

netstat -tulpn
tcp 0 0 0.0.0.0:8585 0.0.0.0:* LISTEN 206126/python
tcp6 0 0 :::8585 :::* LISTEN 206126/python

Cross posted in streamlit.io because i am not sure if this problem is caused by streamlit or server.

Tom Newton avatar
cn flag
- Are there any records in log files (streamlit | python | /var/log ) ? - How about to monitor network activity by ss or netstat command to specify source of the issue
384X21 avatar
cn flag
streamlit logs has no info related to failed app rendering from www. (I guess apps are running fine from the local ip, therefore perhaps streamlit is not showing up any errors in log ?!)
Tom Newton avatar
cn flag
It is good to check whether and in which form streamlit server receives requests. In which state are sockets (ports) for incoming connections during web request. The commands `ss -tulpn` or `netstat -tulpn | grep streamlit` can give listeneng ports with originating ip (suppose thae application name is as indicated). On the other end -- what shows the trace browser's request via _Development tools_?
384X21 avatar
cn flag
@TomNewton: edited question to include output of `ss -tulpn` and browser request trace
Tom Newton avatar
cn flag
it seems, next step will be solving https://www.google.com/search?q=a+websocket+connection+error+occurred Sorry, I'm not deeply familiar with web-programming
Score:0
cn flag

Problem is related to web socket blocked by company server.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.