How can I use Gradio websocket API

I make a Android App with JAVA. I can’t use the Python or JS Gradio API.
Then, I have called Gradio API with REST. It is work ok if process (file) is short time. But It will disconnect if HTTP timeout when processing big file.
Then, I try to use the websocket API(undocument) to connect the Gradio ,
I refer the link https://prog.world/artificial-artist-google-from-text-to-img-world/ .
It looks work a few days, But it will fail alway after some days.
I look the error in spaces’s logs. It will occur when the websocket start to connect, before send any message. I wonder why the server block the connecting? Do I lost some operation?
Then , I have use different Android websocket library (AndroidAsync or autobahn-java]) to check it , It looks like the server issue.
I want konw anyone meeting the issue?

-----------------------------------------------logs---------------------------------------------------------------------
ERROR: Exception in ASGI application
Traceback (most recent call last):
File “/home/user/.local/lib/python3.10/site-packages/uvicorn/protocols/websockets/websockets_impl.py”, line 254, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File “/home/user/.local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py”, line 78, in call
return await self.app(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/fastapi/applications.py”, line 282, in call
await super().call(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/applications.py”, line 122, in call
await self.middleware_stack(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/middleware/errors.py”, line 149, in call
await self.app(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/middleware/cors.py”, line 75, in call
await self.app(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/middleware/exceptions.py”, line 79, in call
raise exc
File “/home/user/.local/lib/python3.10/site-packages/starlette/middleware/exceptions.py”, line 68, in call
await self.app(scope, receive, sender)
File “/home/user/.local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py”, line 20, in call
raise e
File “/home/user/.local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py”, line 17, in call
await self.app(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/routing.py”, line 718, in call
await route.handle(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/routing.py”, line 341, in handle
await self.app(scope, receive, send)
File “/home/user/.local/lib/python3.10/site-packages/starlette/routing.py”, line 82, in app
await func(session)
File “/home/user/.local/lib/python3.10/site-packages/fastapi/routing.py”, line 292, in app
await dependant.call(**values)
File “/home/user/.local/lib/python3.10/site-packages/gradio/routes.py”, line 421, in join_queue
session_info = await websocket.receive_json()
File “/home/user/.local/lib/python3.10/site-packages/starlette/websockets.py”, line 133, in receive_json
self._raise_on_disconnect(message)
File “/home/user/.local/lib/python3.10/site-packages/starlette/websockets.py”, line 105, in _raise_on_disconnect
raise WebSocketDisconnect(message[“code”])
starlette.websockets.WebSocketDisconnect: 1006