ERROR: Exception in ASGI application websockets
Describe the bug
I installed it locally, and after the installation is completed, I started it using the bellow command and reported the error. I asked my friends and they also made the same mistake
langflow --log-level debug
Output log of the console
[11:37:23] INFO [11:37:23] - INFO - Logger set up with log level: 10(debug) logger.py:28
INFO [11:37:23] - INFO - Log file: logs/langflow.log logger.py:30
INFO: Started server process [36465]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:7860 (Press CTRL+C to quit)
DEBUG: = connection is CONNECTING
DEBUG: < GET /chat/ HTTP/1.1
DEBUG: < host: 127.0.0.1:7860
DEBUG: < connection: Upgrade
DEBUG: < pragma: no-cache
DEBUG: < cache-control: no-cache
DEBUG: < user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
DEBUG: < upgrade: websocket
DEBUG: < origin: http://127.0.0.1:7860
DEBUG: < sec-websocket-version: 13
DEBUG: < accept-encoding: gzip, deflate, br
DEBUG: < accept-language: zh-CN,zh;q=0.9,en;q=0.8
DEBUG: < cookie: access-token=vuH9UEGn-sD6mIzAbn8UrQ; access-token-unsecure=vuH9UEGn-sD6mIzAbn8UrQ
DEBUG: < sec-websocket-key: I6EU4VtdimSQgm1qfcCOVw==
DEBUG: < sec-websocket-extensions: permessage-deflate; client_max_window_bits
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 238, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/fastapi/applications.py", line 271, in __call__
await super().__call__(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/applications.py", line 118, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/middleware/errors.py", line 149, in __call__
await self.app(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/middleware/cors.py", line 76, in __call__
await self.app(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/routing.py", line 706, in __call__
await route.handle(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/routing.py", line 443, in handle
await self.app(scope, receive, send)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/starlette/staticfiles.py", line 96, in __call__
assert scope["type"] == "http"
AssertionError
DEBUG: > HTTP/1.1 101 Switching Protocols
DEBUG: > Upgrade: websocket
DEBUG: > Connection: Upgrade
DEBUG: > Sec-WebSocket-Accept: 9A3iAH/t+Z9wBhePk6Yk8kIb+sI=
DEBUG: > Sec-WebSocket-Extensions: permessage-deflate
DEBUG: > date: Wed, 10 May 2023 03:37:23 GMT
DEBUG: > server: uvicorn
INFO: connection open
DEBUG: = connection is OPEN
DEBUG: = connection is CLOSING
DEBUG: > CLOSE 1000 (OK) [2 bytes]
DEBUG: = connection is CLOSED
DEBUG: ! failing connection with code 1006
DEBUG: x half-closing TCP connection
DEBUG: ! failing connection with code 1006
ERROR: closing handshake failed
Traceback (most recent call last):
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 959, in transfer_data
message = await self.read_message()
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1029, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1104, in read_data_frame
frame = await self.read_frame(max_size)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1161, in read_frame
frame = await Frame.read(
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/framing.py", line 68, in read
data = await reader(2)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/streams.py", line 721, in readexactly
raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/server.py", line 248, in handler
await self.close()
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 766, in close
await self.write_close_frame(Close(code, reason))
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1232, in write_close_frame
await self.write_frame(True, OP_CLOSE, data, _state=State.CLOSING)
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1205, in write_frame
await self.drain()
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 1194, in drain
await self.ensure_open()
File "/Users/ruihai/Library/Python/3.9/lib/python/site-packages/websockets/legacy/protocol.py", line 935, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: sent 1000 (OK); no close frame received
INFO: connection closed
I am using a Mac system
13.0.1 (22A400)
Version of my Python package: fastapi 0.92.0 websocket-client 1.5.1 uvicorn 0.20.0 websockets 11.0.3
Hey, @rui-hai. Thanks for opening this issue.
It seems this isn't related to LangFlow. Have you tried upgrading it to the latest version? Could you try using a different Python version like 3.10 or 3.11?
Hi all, I do think this is actually a Langflow issue. Somehow tabs can get into a bad state and can't establish a WS connection
Video of the issue if it helps.
https://github.com/logspace-ai/langflow/assets/5541893/e1d11428-d776-425c-a22b-f28cf4802aa5
The good news is it seems like a quick workaround is just opening a new tab!
@merrickfox cool , I tried the method of creating a new tab, which is indeed possible, but it is still a bug,please fix @ogabrielluiz
Yeah. We'll push a release today that fixes this. Thanks!
@ogabrielluiz In response to my issue, I attempted to upgrade Python 3.9 to Python 3.11.3 and the issue was resolved. After startup, no more errors are reported in console. So please indicate the version that Langflow needs to rely on to avoid unexpected issues caused by Python versions. Thank you.
Now a new problem has arisen. Seeing that someone has already raised the same error report:
https://github.com/logspace-ai/langflow/issues/268
Error building node OpenAI: 2 validation errors for OpenAI allowed_special unhashable type: 'list' (type=type_error) allowed_special instance of Set expected (type=type_error.arbitrary_type; expected_arbitrary_type=Set)
When I switch tabs, I get the above error. I can confirm that my 7860 service is already running and that I'm using the latest version of Python.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
See #298 for ws hard code error
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.