GithubHelp home page GithubHelp logo

Comments (9)

TrueBrain avatar TrueBrain commented on May 13, 2024 1

The odd thing is that I run multiple dibridges in parallel on the same server and only one was affected, so this would speak against an connection issue.

Connection error is more than a connection issue on your side :) In this case, it seems to be the Discord-side.

In more detail, this happens if the Discord backend disconnect us with an error-code that the Discord library is not used to handle. Which means it is a bit undefined what one can do to recover.

One could argue that you can just reconnect to Discord and try again. But the docs suggest that these issues only happen when there is a configuration error on the bot side (wrong token, wrong shard, etc). So it is likely to happen again. But in this case it seems more likely that the Discord platform made a boo-boo, and booted the bot for the wrong reasons. But to differentiate between those scenarios is tricky.

Possibly a way to recover is to just let the whole bridge crash. If you are like me, it will just restart, and continue its operation. But that feels a bit meh. Need to think a bit more about this :)

from dibridge.

TrueBrain avatar TrueBrain commented on May 13, 2024 1

Thank you! So the root-cause was Received fragmented control frame. Which terminated the websocket to Discord, which is an event not handled by the Discord library, and this bridge simply does nothing with it, causing the other exceptions you see.

That is fixable :)

from dibridge.

TrueBrain avatar TrueBrain commented on May 13, 2024 1

Right, should be fixed, and not resurface again :) It now basically reconnects automatically in such events.

Thank you for the reports and additional information. Dibridge is now one step better than it was before :D

from dibridge.

TrueBrain avatar TrueBrain commented on May 13, 2024

That means the loop was made sentinal (basically, NULL'd), which is .. odd, to say the least. I did not know Python was capable of doing that.

I have not seen this error myself, but we are also running on Python 3.10. That might or might not be related.

This needs a bit of investigating :D A very interesting (but concerning) problem :P

from dibridge.

TrueBrain avatar TrueBrain commented on May 13, 2024

Ah, no, I was misreading the backtrace, and misremembering what the code does :)

It appears that the Discord connection was closed. This also resets the loop variable (to a sentinel value). So that explains the issue there.

This might happen when there is a connection error, but I thought it self-restored. Clearly, it does not. But that is an easy thing to experiment with, as that should be reproduceable :D Will look into it further!

from dibridge.

poVoq avatar poVoq commented on May 13, 2024

The odd thing is that I run multiple dibridges in parallel on the same server and only one was affected, so this would speak against an connection issue.

from dibridge.

TrueBrain avatar TrueBrain commented on May 13, 2024

One more question for you: how far back do your logs go? It is likely there was a backtrace just before these errors you pasted started. It would be interesting to see that error, if possible?

PS: https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes these are the possible reasons the connection got closed. A few stand out, for example "rate limited" could ofc happen if IRC is really chatty. Or "session timed out" if the bridge is just connected for too long to Discord. But the Discord library I use handles these cases poorly, so I will need to wrap around those cases :)

from dibridge.

poVoq avatar poVoq commented on May 13, 2024

No, the bridged channel is pretty quiet, so I doubt is was a rate limit error.

Edit: Ok this seems to be what you wanted:

IRCBridge[1052527]: Exception in thread Thread-1 (start):
IRCBridge[1052527]: Traceback (most recent call last):
IRCBridge[1052527]:   File "/usr/lib64/python3.11/threading.py", line 1045, in _bootstrap_inner
IRCBridge[1052527]:     self.run()
IRCBridge[1052527]:   File "/usr/lib64/python3.11/threading.py", line 982, in run
IRCBridge[1052527]:     self._target(*self._args, **self._kwargs)
IRCBridge[1052527]:   File "/dibridge/discord.py", line 198, in start
IRCBridge[1052527]:     relay.DISCORD.run(token, log_handler=None)
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/client.py", line 860, in run
IRCBridge[1052527]:     asyncio.run(runner())
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/runners.py", line 190, in run
IRCBridge[1052527]:     return runner.run(main)
IRCBridge[1052527]:            ^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/runners.py", line 118, in run
IRCBridge[1052527]:     return self._loop.run_until_complete(task)
IRCBridge[1052527]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/base_events.py", line 654, in run_until_complete
IRCBridge[1052527]:     return future.result()
IRCBridge[1052527]:            ^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/client.py", line 849, in runner
IRCBridge[1052527]:     await self.start(token, reconnect=reconnect)
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/client.py", line 778, in start
IRCBridge[1052527]:     await self.connect(reconnect=reconnect)
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/client.py", line 659, in connect
IRCBridge[1052527]:     await self.ws.poll_event()
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/gateway.py", line 626, in poll_event
IRCBridge[1052527]:     raise msg.data
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/client_ws.py", line 244, in receive
IRCBridge[1052527]:     msg = await self._reader.read()
IRCBridge[1052527]:           ^^^^^^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/streams.py", line 663, in read
AIRCBridge[1052527]:     return await super().read()
IRCBridge[1052527]:            ^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/streams.py", line 622, in read
IRCBridge[1052527]:     await self._waiter
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/http_websocket.py", line 314, in feed_data
IRCBridge[1052527]:     return self._feed_data(data)
IRCBridge[1052527]:            ^^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/http_websocket.py", line 321, in _feed_data
IRCBridge[1052527]:     for fin, opcode, payload, compressed in self.parse_frame(data):
IRCBridge[1052527]:                                             ^^^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/aiohttp/http_websocket.py", line 486, in parse_frame
IRCBridge[1052527]:     raise WebSocketError(
IRCBridge[1052527]: aiohttp.http_websocket.WebSocketError: Received fragmented control frame
IRCBridge[1052527]: Exception in thread Thread-334:
IRCBridge[1052527]: Traceback (most recent call last):
IRCBridge[1052527]:   File "/usr/lib64/python3.11/threading.py", line 1045, in _bootstrap_inner
IRCBridge[1052527]:     self.run()
IRCBridge[1052527]:   File "/dibridge/.env/lib64/python3.11/site-packages/discord/gateway.py", line 169, in run
IRCBridge[1052527]:     f = asyncio.run_coroutine_threadsafe(coro, loop=self.ws.loop)
IRCBridge[1052527]:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/tasks.py", line 936, in run_coroutine_threadsafe
IRCBridge[1052527]:     loop.call_soon_threadsafe(callback)
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/base_events.py", line 807, in call_soon_threadsafe
IRCBridge[1052527]:     self._check_closed()
IRCBridge[1052527]:   File "/usr/lib64/python3.11/asyncio/base_events.py", line 520, in _check_closed
IRCBridge[1052527]:     raise RuntimeError('Event loop is closed')
IRCBridge[1052527]: RuntimeError: Event loop is closed
IRCBridge[1052527]: /usr/lib64/python3.11/threading.py:1047: RuntimeWarning: coroutine 'DiscordWebSocket.send_heartbeat' was never awaited
IRCBridge[1052527]:   self._invoke_excepthook(self)
IRCBridge[1052527]: RuntimeWarning: Enable tracemalloc to get the object allocation traceback

from dibridge.

poVoq avatar poVoq commented on May 13, 2024

Updated the above error log, sorry for the previous one I mistakenly thought was not the same.

from dibridge.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.