Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

BUG-KeyError: 'Session is disconnected' #1146

Closed MarkAngler closed 5 months ago

MarkAngler commented 5 months ago

Description Deploying Taipy to Azure App Services results in 2024-04-09T13:28:03.433854674Z KeyError: 'Session is disconnected'. Pages eventually load, but take an extremely long time. App service is https, documentation only shows a http example. Full error

2024-04-09T13:29:54.283250358Z   File "/opt/python/3.9.18/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 135, in handle
2024-04-09T13:29:54.283254358Z     self.handle_request(listener, req, client, addr)
2024-04-09T13:29:54.283258158Z   File "/opt/python/3.9.18/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 178, in handle_request
2024-04-09T13:29:54.283262558Z     respiter = self.wsgi(environ, resp.start_response)
2024-04-09T13:29:54.283266458Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/flask/app.py", line 1488, in __call__
2024-04-09T13:29:54.283270458Z     return self.wsgi_app(environ, start_response)
2024-04-09T13:29:54.283274458Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/flask_socketio/__init__.py", line 43, in __call__
2024-04-09T13:29:54.283278358Z     return super(_SocketIOMiddleware, self).__call__(environ,
2024-04-09T13:29:54.283293059Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/engineio/middleware.py", line 63, in __call__
2024-04-09T13:29:54.283297859Z     return self.engineio_app.handle_request(environ, start_response)
2024-04-09T13:29:54.283302159Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/socketio/server.py", line 430, in handle_request
2024-04-09T13:29:54.283306459Z     return self.eio.handle_request(environ, start_response)
2024-04-09T13:29:54.283310459Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/engineio/server.py", line 272, in handle_request
2024-04-09T13:29:54.283314459Z     socket = self._get_socket(sid)
2024-04-09T13:29:54.283318959Z   File "/tmp/8dc5898710935b6/antenv/lib/python3.9/site-packages/engineio/base_server.py", line 229, in _get_socket
2024-04-09T13:29:54.283322859Z     raise KeyError('Session is disconnected')
2024-04-09T13:29:54.283326459Z KeyError: 'Session is disconnected'

How to reproduce Deploy a https azure app service, web service

pages = { "/": root.root, "ProductServices": productservices.ProductServices, "EdmHandbookRag": edm.EdmHandbookRag }

tp_app = Gui(pages=pages)

if name == "main": tp_app.run(debug=True, use_reloader=True) # , async_mode='standalone' else:

Production mode, Azure Web Application runs the application with Gunicorn.

app = tp_app.run(run_server=False, port=8000, title="LLM", debug=True, ) #, async_mode='standalone'


- And/or configuration files or code:
    ```python
    ...

Expected behavior No errors

Screenshots

Runtime environment Python 3.9, linux app service databricks_vectorsearch==0.28 langchain==0.1.14 langchain-community==0.0.31 langchain-core==0.1.40 langchain-text-splitters==0.0.1 langsmith==0.1.40 openai==1.16.2 taipy==3.1.1 taipy-config==3.1.1 taipy-core==3.1.1 taipy-gui==3.1.1 taipy-rest==3.1.1 taipy-templates==3.1.1

Acceptance Criteria

MarkAngler commented 5 months ago

disabled https, same issue

disabled debug, got a new error -

2024-04-09T16:17:56.859672955Z   File "/opt/python/3.9.18/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 135, in handle
2024-04-09T16:17:56.859677755Z     self.handle_request(listener, req, client, addr)
2024-04-09T16:17:56.859682255Z   File "/opt/python/3.9.18/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 178, in handle_request
2024-04-09T16:17:56.859686855Z     respiter = self.wsgi(environ, resp.start_response)
2024-04-09T16:17:56.859691055Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/flask/app.py", line 1488, in __call__
2024-04-09T16:17:56.859732356Z     return self.wsgi_app(environ, start_response)
2024-04-09T16:17:56.859737656Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/flask_socketio/__init__.py", line 43, in __call__
2024-04-09T16:17:56.859741656Z     return super(_SocketIOMiddleware, self).__call__(environ,
2024-04-09T16:17:56.859745556Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/engineio/middleware.py", line 63, in __call__
2024-04-09T16:17:56.859749556Z     return self.engineio_app.handle_request(environ, start_response)
2024-04-09T16:17:56.859753756Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/socketio/server.py", line 430, in handle_request
2024-04-09T16:17:56.859758156Z     return self.eio.handle_request(environ, start_response)
2024-04-09T16:17:56.859762856Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/engineio/server.py", line 274, in handle_request
2024-04-09T16:17:56.859767756Z     packets = socket.handle_get_request(
2024-04-09T16:17:56.859772156Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/engineio/socket.py", line 90, in handle_get_request
2024-04-09T16:17:56.859777057Z     return getattr(self, '_upgrade_' + transport)(environ,
2024-04-09T16:17:56.859781657Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/engineio/socket.py", line 146, in _upgrade_websocket
2024-04-09T16:17:56.859786257Z     return ws(environ, start_response)
2024-04-09T16:17:56.859790657Z   File "/tmp/8dc58afcd86fa09/antenv/lib/python3.9/site-packages/engineio/async_drivers/gevent.py", line 54, in __call__
2024-04-09T16:17:56.859795357Z     raise RuntimeError('The gevent-websocket server is not '
2024-04-09T16:17:56.859799757Z RuntimeError: The gevent-websocket server is not configured appropriately. See the Deployment section of the documentation for more information.
MarkAngler commented 5 months ago

Fixed with custom startup cmd gunicorn -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -w 1 -b 0.0.0.0:8000 app:app ?

MarkAngler commented 5 months ago

Resolution above

FlorianJacta commented 5 months ago

Thank you for the issue and its solution. We will make sure to update the doc accordingly.

I don't know if you use Taipy Core features with scenario and data management, but Gunicorn has limitations when using execution mode. You could use our command line interface (taipy run ...) to run Taipy.

swateek commented 5 days ago

I changed the port on the CMD and also in tp.run, still see the same issue.

FlorianJacta commented 3 days ago

Could you describe your issue and how did you produce the error? @swateek