streamlit: Multipage app v2 - reloading a page generates websocket connection error on Windows

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Select the basketball page and press reload page button (google chrome browser), generates web socket connection error continuously.

I believe this is a serious bug and deserves a higher priority. We cannot prevent users from pressing that reload button.

image

image

Reproducible Code Example

"""
streamlit==1.36.0
"""


import streamlit as st


def Home():
    st.header('Home')


def Basketball():
    st.header('Basketball')


pg = st.navigation(
    [
        st.Page(Home),
        st.Page(Basketball)
    ]
)
pg.run()

Steps To Reproduce

Run the code, select basketball page and press the reload button of the browser.

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.36.0
  • Python version: 3.11.7
  • Operating System: Windows 10
  • Browser: Google chrome

Additional Information

https://discuss.streamlit.io/t/launched-multi-page-apps-improved-api-and-new-navigation-ui-features/65679/31

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 21 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Hey @fsmosca and @tpougy! I was able to reproduce the issue and I figured out the problem. We identify the websocket connection by attempting to connect on the root url first. We fail a test detecting an incorrect connection because of the file separator syntax (what I thought was URL syntax is actually a file syntax). I should have a fix and I can post a wheel file to test this out before merging.

Really appreciate your help in diagnosing!

Hey @fsmosca and @tpougy mind trying out this wheel file and verify this works correctly for you.

To Install

  1. Download the following ZIP file. streamlit-1.36.0-py2.py3-none-any.zip
  2. Rename the extension from .zip to .whl
  3. install with pip install streamlit-1.36.0-py2.py3-none-any.whl

I might recommend uninstalling streamlit (pip uninstall streamlit) beforehand to avoid any conflict.

I also see this websocket error in my windows dev environment. The error does not occur after deploying to an on premise linux server that we have in the company where I work.

I tried checking the streamlit DEBUG logs but there is no feedback from the log after reloading the page, it’s as if the connection wasn’t even registred by the framework.

@fsmosca I’ll take a look on this. It seems to be tied to Windows specifically.

@sfc-gh-jcarroll the 404s are currently expected behavior, but perhaps we can look to simplify. When someone navigates to the page, we assume the host config/connection is on that url, if it fails, we move up a url path directory (and assume we are on a page, and need to the main URL. We should probably look into a solution that would always make the first call work (or provide the correct URL) on load.

When I run the code on a Mac I’m not able to repro this, but on Windows, I am able to reproduce the issue.

Here is what I found:

The app is running and all pages are working as expected until you go to the 2nd or 3rd page ( Basketball, Tennis) and reload the page. Then the problem starts. I deployed the app code below. This problem is not appearing on the cloud, only locally and only on Windows. `import streamlit as st

def Home(): st.header(‘Home’)

def Basketball(): st.header(‘Basketball’)

def Tennis(): st.header(‘Tennis’)

pg = st.navigation( [ st.Page(Home), st.Page(Basketball), st.Page(Tennis) ] ) pg.run() ` https://test-mvp2.streamlit.app/

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits