Strange behaviour when reverse proxying through IIS on AWS ec2

Good evening everyone,

I wonder if you may help me making sense of what I perceive as strange behaviour when deploying streamlit on a Amazon ec2 Windows instance. This follows roughly two weeks of failed attempts, google searches and all sorts of potential wizardry at my disposal.

My intention is to expose a streamlit app through the public IP of a ec2 Windows Server 2019 instance. When accessing the instance via localhost on the default port 8501, it works wonderfully.

I have set up a IIS reverse proxy, using URL Rewrite/Web Platform Installing, with a rule proxying to the localhost:8501, as follows:

(I attempted with both localhost and the private IP, as well as the ticket box “stop processing of subsequent rules”)

This solution was the closest I got to actual success - in that at least it shows something when I access from the external networks - but unfortunately only shows a flashing “Connecting” test at the right top side and the “Please wait…” note. The issue is that the exposed page just keeps refreshing and doesn’t actual access the script - and this is accurate for both running an own developed script or just the hello.

Similarly, I have disabled the CORS and Xsrf as potential workarounds, with no different outcome. I also have install the websockets extension for IIS, to no avail.

Through the debug mode, I received the following messages, which I am uncertain document the issue at hand:

2020-11-03 19:34:07.528 Task exception was never retrieved
future: <Task finished name='Task-8' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at c:\programdata\miniconda3\lib\site-packages\tornado\> exception=WebSocketClosedError()>
Traceback (most recent call last):
  File "c:\programdata\miniconda3\lib\site-packages\tornado\", line 1104, in wrapper
    await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\programdata\miniconda3\lib\site-packages\tornado\", line 1106, in wrapper
    raise WebSocketClosedError()

I wonder if anyone has gone through this endeavour and returned victorious. :slight_smile:

Have a wonderful week,

Hi @miguel, welcome to the Streamlit community!

Before digging too deeply into this, my first question when running into these types of issues is “Do you have to run a Windows server?” Unless you’re using someone else’s instance (and you can’t change it), or your app needs specific Windows functionality, it’s way easier to deploy any app using a Linux server.

Hi Randy,

Thank you. :slight_smile:

I know precisely where you’re coming from - and yes, unfortunately. I could go into the details of the matlab-derived code that require that (or at least, without major re-architecture of the data flows) - but the bottomline is yes.

In addition, I can not even get streamlit to grab the public ip details from the windows machine, which in Linux is basically just setting it up in the config.toml.

My Linux instances run fine.

1 Like