St.chat_message enter does not post

Hi community,

I am gearing to deploy a streamlit chatbot into production, but am noticing some hiccups in the tool, and I am not sure how best I can address it:

  • connection being lost (browser inactivity leads to it) - it just shows “connecting” on the top right forever.
  • chat_message - write something and hit enter, the information is just lost (does not post) - I can’t consistently reproduce this

Has anyone experience this kind of issue before? How can I go about trying to debug or collect logs to understand what and why this is happening?

More details:
App deployed in Azure (internal to the organisation) as an App Service, python 3.8
Using the following libraries:

streamlit                                1.29.0
streamlit-camera-input-live              0.2.0
streamlit-card                           0.0.61
streamlit-embedcode                      0.1.2
streamlit-extras                         0.3.5
streamlit-faker                          0.0.3
streamlit-image-coordinates              0.1.6
streamlit-keyup                          0.2.0
streamlit-toggle-switch                  1.0.2
streamlit-vertical-slider                1.0.2
1 Like

Hi @brunobraga,

Thanks for posting!

Is this issue happening also locally or just in prod on Azure? Are you able to share any code for this app or just the chat message and chat input logic?

The first problem happens intermittently… a message pops up in a white box top center: Connection failed with status 0.

The code is private IP, but here is a slight modified version if it helps troubleshooting:

if "messages" not in st.session_state:
    st.session_state.messages = []

for message in st.session_state.messages:
    with st.chat_message(message["role"]):
        st.markdown(message["content"])

if prompt := st.chat_input("How can I help you?"):
    st.session_state.messages.append({"role": "user", "content": prompt})
    with st.chat_message("user"):
        st.markdown(prompt)
    with st.chat_message("assistant"):
        message_placeholder = st.empty()
        full_response = "response from action" # whatever API
        message_placeholder.markdown(full_response)
        st.session_state.messages.append({"role": "assistant", "content": full_response})

1 Like

Thanks for the info.

The code snippet above looks good. My guess would be that the issue is coming from the deployment on Azure.

Does it work locally when you run it with no issues?

Trying to tease out if it is something to do with deployment on Azure.

Thanks Tony for helping out. I can replicate the first issue locally but happens intermittently, just leave a page running overnight (for hours of inactivity) I could see it stuck in “connecting…”

How can I further troubleshoot this?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.