vuer-ai / vuer

Vuer is a 3D visualization tool for robotics and VR applications.
https://docs.vuer.ai
MIT License
119 stars 3 forks source link

Can't run examples - uplink:<ws_id> is not in websocket pool #23

Closed PositiveBeat closed 1 week ago

PositiveBeat commented 1 month ago

Hello!

I've been trying to run the examples but with no luck so far. When running the example from the README:

from vuer import Vuer, VuerSession
from vuer.schemas import DefaultScene, Urdf

app = Vuer()

@app.spawn(start=True)
async def main(session: VuerSession):
    app.set @ DefaultScene(
        Urdf("assets/urdf/cylinder.urdf"), # simple cylinder urdf
    )

    while True:
        await session.sleep(0.1)

I get the following error:

Serving file:///home/user/workspace/vuer at /static
Visit: https://vuer.ai
websocket is connected. id:9308688b-ae55-47f3-8c0e-3250cca3faeb
default socket worker is up, adding clientEvents 
Uplink task running. id:9308688b-ae55-47f3-8c0e-3250cca3faeb
uplink:9308688b-ae55-47f3-8c0e-3250cca3faeb is not in websocket pool
websocket is now disconnected. Removing the socket.
WebSocket connection closed
Task exception was never retrieved
future: <Task finished name='Task-7' coro=<Vuer.downlink.<locals>.handler() done, defined at /home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/vuer/server.py:573> exception=AttributeError("attribute set does not exist on {'_prefix': None, 'name': 'vuer', 'domain': 'https://vuer.ai', 'port': 8012, 'free_port': True, 'static_root': '.', 'queue_len': 100, 'cors': 'https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*', 'queries': {}, 'cert': None, 'key': None, 'ca_cert': None, 'client_root': PosixPath('/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/vuer/client_build'), 'device': 'cuda', 'host': 'localhost', 'WEBSOCKET_MAX_SIZE': 268435456, 'REQUEST_MAX_SIZE': 268435456, 'app': <Application 0x74391e995ba0>, 'cors_context': <aiohttp_cors.cors_config.CorsConfig object at 0x74391e995cc0>, 'handlers': defaultdict(<class 'dict'>, {}), 'page': <vuer.schemas.html_components.Page object at 0x74391e995c30>, 'ws': {UUID('9308688b-ae55-47f3-8c0e-3250cca3faeb'): <WebSocketResponse Switching Protocols GET / >}, 'socket_handler': <function main at 0x74391e80d1b0>, 'spawned_coroutines': []}")>
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/waterbear/waterbear.py", line 156, in __getattr__
    value = self.__d[item]
KeyError: 'set'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/vuer/server.py", line 579, in handler
    raise e
  File "/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/vuer/server.py", line 575, in handler
    await self.socket_handler(vuer_proxy)
  File "/home/user/workspace/vuer/src/vuer_simple_example.py", line 9, in main
    app.set @ DefaultScene(
  File "/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/waterbear/waterbear.py", line 171, in __getattr__
    raise AttributeError("attribute {} does not exist on {}".format(item, __d))
AttributeError: attribute set does not exist on {'_prefix': None, 'name': 'vuer', 'domain': 'https://vuer.ai', 'port': 8012, 'free_port': True, 'static_root': '.', 'queue_len': 100, 'cors': 'https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*', 'queries': {}, 'cert': None, 'key': None, 'ca_cert': None, 'client_root': PosixPath('/home/user/.local/share/virtualenvs/vuer-QS3x9RZp/lib/python3.10/site-packages/vuer/client_build'), 'device': 'cuda', 'host': 'localhost', 'WEBSOCKET_MAX_SIZE': 268435456, 'REQUEST_MAX_SIZE': 268435456, 'app': <Application 0x74391e995ba0>, 'cors_context': <aiohttp_cors.cors_config.CorsConfig object at 0x74391e995cc0>, 'handlers': defaultdict(<class 'dict'>, {}), 'page': <vuer.schemas.html_components.Page object at 0x74391e995c30>, 'ws': {UUID('9308688b-ae55-47f3-8c0e-3250cca3faeb'): <WebSocketResponse Switching Protocols GET / >}, 'socket_handler': <function main at 0x74391e80d1b0>, 'spawned_coroutines': []}

I think the root of the error is the very first lines, specifically uplink:<ws_id> is not in websocket pool, which is thrown in the uplink function from the server source code. This issue is likely related to https://github.com/vuer-ai/vuer/issues/21, but the error is a bit different.

I'm on Ubuntu 22.04, Python 3.10, and have run pip install vuer in a virtual environment. I also tested on Windows 11 with the same result.

I hope this is enough info, thanks in advance for any help!

geyang commented 3 weeks ago

I will take a look and get back to you asap.

geyang commented 1 week ago

this line:

await session.sleep(0.1)

has been deprecated. Use asyncio.sleep instead.

I am closing this, feel free to reopen if problem persists!

PositiveBeat commented 1 week ago

@geyang I have changed the code to this:

from vuer import Vuer, VuerSession
from vuer.schemas import DefaultScene, Urdf
import asyncio

app = Vuer()

@app.spawn(start=True)
async def main(session: VuerSession):
    app.set @ DefaultScene(
        Urdf("assets/urdf/cylinder.urdf"),
    )

    while True:
        await asyncio.sleep(0.1)      # Using asyncio instead of session.sleep(0.1)

The terminal still throws the same error. I don't have permission to reopen the issue, would you be able to do that in my stead?

Thank you.