Skip to content

Websocket is close #49

@Guevin1

Description

@Guevin1

code:

async def main():
    vts = pyvts.vts(plugin_info=plugin_info)
    await vts.connect()
    await vts.request_authenticate_token()  # get token
    await vts.request_authenticate()  # use token
    new_parameter_name = "start_parameter"
    await vts.request(
        vts.vts_request.requestCustomParameter(new_parameter_name)
    )
    global MyVts, character_id, emotions
    MyVts = vts

    while True:
        character_new = await MyVts.request(MyVts.vts_request.BaseRequest("CurrentModelRequest"))
        character_new = character_new["data"]

        if character_new["modelID"] != character_id:
            response_data = await vts.request(vts.vts_request.requestHotKeyList())
            hotkey_list = []
            for hotkey in response_data['data']['availableHotkeys']:
                hotkey_list.append(hotkey['name'])
            emotions = hotkey_list
            character_id = character_new["modelID"]
            print("new vtuber's avatar")
            print(emotions)
        inp = input("Эмоция: ")
        if inp == "stop":
            break

        await emotion(inp)


async def emotion(name):
    ID = 0
    if name in emotions:
        ID = emotions.index(name)
        print("emotion found")
    send_hotkey_request = MyVts.vts_request.requestTriggerHotKey(emotions[ID])
    await MyVts.request(send_hotkey_request) # send request to play 'My Animation 1'

Error

Traceback (most recent call last):
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1192, in drain
    await self._drain()
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 334, in _drain
    raise exc
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 963, in transfer_data
    message = await self.read_message()
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1033, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1108, in read_data_frame
    frame = await self.read_frame(max_size)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1165, in read_frame
    frame = await Frame.read(
            ^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/framing.py", line 68, in read
    data = await reader(2)
           ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/streams.py", line 741, in readexactly
    raise self._exception
  File "/usr/lib/python3.12/asyncio/selector_events.py", line 1075, in write
    n = self._sock.send(data)
        ^^^^^^^^^^^^^^^^^^^^^
BrokenPipeError: [Errno 32] Broken pipe

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/guevin1/Рабочий стол/Проекты/vtuber/emotion.py", line 52, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/guevin1/Рабочий стол/Проекты/vtuber/emotion.py", line 40, in main
    await emotion(inp)
  File "/home/guevin1/Рабочий стол/Проекты/vtuber/emotion.py", line 49, in emotion
    await MyVts.request(send_hotkey_request) # send request to play 'My Animation 1'
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/pyvts/vts.py", line 113, in request
    response_msg = await self.websocket.recv()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 568, in recv
    await self.ensure_open()
  File "/home/guevin1/.local/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 939, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions