Websocket error for self hosted Revolt #39

Closed
opened 2026-02-15 23:16:20 -05:00 by yindo · 1 comment
Owner

Originally created by @Daeloce on GitHub (Oct 25, 2024).

Hello. I'm have self hosted Revolt server and try write bot for it. But example code, with custom api_url doesn't work with error:

Traceback (most recent call last):
  File "C:\work\python\revolt-bot\main.py", line 17, in <module>
    asyncio.run(main())
  File ".....conda\envs\revolt-bot\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File ".....conda\envs\revolt-bot\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".....conda\envs\revolt-bot\Lib\asyncio\base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\work\python\revolt-bot\main.py", line 15, in main
    await client.start()
  File ".....conda\envs\revolt-bot\Lib\site-packages\revolt\client.py", line 119, in start
    await self.websocket.start(reconnect)
  File ".....conda\envs\revolt-bot\Lib\site-packages\revolt\websocket.py", line 475, in start
    self.websocket = await self.session.ws_connect(url)  # type: ignore
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".....conda\envs\revolt-bot\Lib\site-packages\aiohttp\client.py", line 821, in _ws_connect
    raise WSServerHandshakeError(
aiohttp.client_exceptions.WSServerHandshakeError: 200, message='Invalid response status', url=URL('ws://self-hosted/events?format=msgpack')

Code of main.py:

import revolt
import asyncio


class Client(revolt.Client):
    async def on_message(self, message: revolt.Message):
        if message.content == "hello":
            await message.channel.send("hi how are you")


async def main():
    async with revolt.utils.client_session() as session:
        client = Client(session, "bot-token",
                        api_url="http://self-hosted/api")
        await client.start()

asyncio.run(main())
Originally created by @Daeloce on GitHub (Oct 25, 2024). Hello. I'm have self hosted Revolt server and try write bot for it. But example code, with custom api_url doesn't work with error: ``` Traceback (most recent call last): File "C:\work\python\revolt-bot\main.py", line 17, in <module> asyncio.run(main()) File ".....conda\envs\revolt-bot\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File ".....conda\envs\revolt-bot\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".....conda\envs\revolt-bot\Lib\asyncio\base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\work\python\revolt-bot\main.py", line 15, in main await client.start() File ".....conda\envs\revolt-bot\Lib\site-packages\revolt\client.py", line 119, in start await self.websocket.start(reconnect) File ".....conda\envs\revolt-bot\Lib\site-packages\revolt\websocket.py", line 475, in start self.websocket = await self.session.ws_connect(url) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".....conda\envs\revolt-bot\Lib\site-packages\aiohttp\client.py", line 821, in _ws_connect raise WSServerHandshakeError( aiohttp.client_exceptions.WSServerHandshakeError: 200, message='Invalid response status', url=URL('ws://self-hosted/events?format=msgpack') ``` Code of main.py: ``` import revolt import asyncio class Client(revolt.Client): async def on_message(self, message: revolt.Message): if message.content == "hello": await message.channel.send("hi how are you") async def main(): async with revolt.utils.client_session() as session: client = Client(session, "bot-token", api_url="http://self-hosted/api") await client.start() asyncio.run(main()) ```
yindo added the invalid label 2026-02-15 23:16:20 -05:00
yindo closed this issue 2026-02-15 23:16:20 -05:00
Author
Owner

@Zomatree commented on GitHub (Oct 29, 2024):

This seems like a configuration issue on the third-party instance, please insure the websocket url given from the api is correct.

@Zomatree commented on GitHub (Oct 29, 2024): This seems like a configuration issue on the third-party instance, please insure the websocket url given from the api is correct.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stoatchat/python-client-sdk#39